diff --git a/.editorconfig b/.editorconfig index 0fd4d6c..13e9c39 100644 --- a/.editorconfig +++ b/.editorconfig @@ -179,3 +179,8 @@ indent_size = 2 [*.gypi] indent_style = space indent_size = 2 + +# Set properties for citation files: +[*.{cff,cff.txt}] +indent_style = space +indent_size = 2 diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index eb8e042..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T02:36:36.571Z diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml index 334eb59..91f2b93 100644 --- a/.github/workflows/productionize.yml +++ b/.github/workflows/productionize.yml @@ -82,21 +82,6 @@ jobs: id: transform-error-messages uses: stdlib-js/transform-errors-action@main - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - name: 'Update dependencies in package.json' run: | diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..2ec6fff --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,30 @@ +cff-version: 1.2.0 +title: stdlib +message: >- + If you use this software, please cite it using the + metadata from this file. + +type: software + +authors: + - name: The Stdlib Authors + url: https://github.com/stdlib-js/stdlib/graphs/contributors + +repository-code: https://github.com/stdlib-js/stdlib +url: https://stdlib.io + +abstract: | + Standard library for JavaScript and Node.js. + +keywords: + - JavaScript + - Node.js + - TypeScript + - standard library + - scientific computing + - numerical computing + - statistical computing + +license: Apache-2.0 AND BSL-1.0 + +date-released: 2016 diff --git a/README.md b/README.md index 7066e2f..76ff31c 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,17 @@ limitations under the License. --> + +
+ + About stdlib... + +

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

+

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

+

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

+

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

+
+ # iterPop [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] @@ -267,8 +278,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [npm-image]: http://img.shields.io/npm/v/@stdlib/iter-pop.svg [npm-url]: https://npmjs.org/package/@stdlib/iter-pop -[test-image]: https://github.com/stdlib-js/iter-pop/actions/workflows/test.yml/badge.svg?branch=main -[test-url]: https://github.com/stdlib-js/iter-pop/actions/workflows/test.yml?query=branch:main +[test-image]: https://github.com/stdlib-js/iter-pop/actions/workflows/test.yml/badge.svg?branch=v0.1.0 +[test-url]: https://github.com/stdlib-js/iter-pop/actions/workflows/test.yml?query=branch:v0.1.0 [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/iter-pop/main.svg [coverage-url]: https://codecov.io/github/stdlib-js/iter-pop?branch=main diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..81be88f --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3 @@ +/// +import iterPop from '../docs/types/index'; +export = iterPop; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..9099421 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,5 @@ +"use strict";var w=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=w(function(L,g){ +var f=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),m=require('@stdlib/assert-is-function/dist'),b=require('@stdlib/assert-is-iterator-like/dist'),v=require('@stdlib/symbol-iterator/dist'),h=require('@stdlib/utils-noop/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function p(e,r,l){var u,n,a,i,s;if(!b(e))throw new TypeError(d('0Pb46',e));if(arguments.length>1){if(!m(r))throw new TypeError(d('0Pb2H',r));i=r}else i=h;return s=0,n={},f(n,"next",c),f(n,"return",x),v&&m(e[v])&&f(n,v,y),n;function c(){var o,t;return a?{done:!0}:(t=e.next(),s===0?(s+=1,t.done?(a=!0,t):(u=t.value,c())):t.done?(a=!0,i.call(l,u),t):(o={value:u,done:!1},u=t.value,o))}function x(o){return a=!0,arguments.length?{value:o,done:!0}:{done:!0}}function y(){return p(e[v](),i,l)}}g.exports=p +});var F=q();module.exports=F; +/** @license Apache-2.0 */ +//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..d60b2ff --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../lib/main.js", "../lib/index.js"], + "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isIteratorLike = require( '@stdlib/assert-is-iterator-like' );\nvar iteratorSymbol = require( '@stdlib/symbol-iterator' );\nvar noop = require( '@stdlib/utils-noop' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an iterator which skips the last value of a provided iterator.\n*\n* @param {Iterator} iterator - input iterator\n* @param {Function} [clbk] - callback to invoke with the skipped value\n* @param {*} [thisArg] - callback execution context\n* @throws {TypeError} first argument must be an iterator protocol-compliant object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var array2iterator = require( '@stdlib/array-to-iterator' );\n*\n* var iter = iterPop( array2iterator( [ 1, 2 ] ) );\n*\n* var v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nfunction iterPop( iterator, clbk, thisArg ) {\n\tvar last;\n\tvar iter;\n\tvar FLG;\n\tvar cb;\n\tvar i;\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t} else {\n\t\tcb = noop;\n\t}\n\ti = 0;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator` and the provided iterator is iterable, make the iterator iterable:\n\tif ( iteratorSymbol && isFunction( iterator[ iteratorSymbol ] ) ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\tvar out;\n\t\tvar v;\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tv = iterator.next();\n\t\tif ( i === 0 ) {\n\t\t\ti += 1;\n\t\t\tif ( v.done ) {\n\t\t\t\tFLG = true;\n\t\t\t\treturn v;\n\t\t\t}\n\t\t\tlast = v.value;\n\t\t\treturn next();\n\t\t}\n\t\tif ( v.done ) {\n\t\t\tFLG = true;\n\t\t\tcb.call( thisArg, last );\n\t\t\treturn v;\n\t\t}\n\t\tout = {\n\t\t\t'value': last,\n\t\t\t'done': false\n\t\t};\n\t\tlast = v.value;\n\t\treturn out;\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn iterPop( iterator[ iteratorSymbol ](), cb, thisArg );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterPop;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an iterator which skips the last value of a provided iterator.\n*\n* @module @stdlib/iter-pop\n*\n* @example\n* var array2iterator = require( '@stdlib/array-to-iterator' );\n* var iterPop = require( '@stdlib/iter-pop' );\n*\n* var iter = iterPop( array2iterator( [ 1, 2 ] ) );\n*\n* var v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], + "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAa,QAAS,4BAA6B,EACnDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAiB,QAAS,yBAA0B,EACpDC,EAAO,QAAS,oBAAqB,EACrCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAASC,EAAUC,EAAMC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,CAACZ,EAAgBK,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,+FAAgGE,CAAS,CAAE,EAEzI,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAK,CAAE,EAE3GK,EAAKL,CACN,MACCK,EAAKT,EAEN,OAAAU,EAAI,EAGJH,EAAO,CAAC,EACRX,EAAaW,EAAM,OAAQI,CAAK,EAChCf,EAAaW,EAAM,SAAUK,CAAI,EAG5Bb,GAAkBF,EAAYM,EAAUJ,CAAe,CAAE,GAC7DH,EAAaW,EAAMR,EAAgBc,CAAQ,EAErCN,EAQP,SAASI,GAAO,CACf,IAAIG,EACAC,EACJ,OAAKP,EACG,CACN,KAAQ,EACT,GAEDO,EAAIZ,EAAS,KAAK,EACbO,IAAM,GACVA,GAAK,EACAK,EAAE,MACNP,EAAM,GACCO,IAERT,EAAOS,EAAE,MACFJ,EAAK,IAERI,EAAE,MACNP,EAAM,GACNC,EAAG,KAAMJ,EAASC,CAAK,EAChBS,IAERD,EAAM,CACL,MAASR,EACT,KAAQ,EACT,EACAA,EAAOS,EAAE,MACFD,GACR,CASA,SAASF,EAAKI,EAAQ,CAErB,OADAR,EAAM,GACD,UAAU,OACP,CACN,MAASQ,EACT,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,CACD,CAQA,SAASH,GAAU,CAClB,OAAOX,EAASC,EAAUJ,CAAe,EAAE,EAAGU,EAAIJ,CAAQ,CAC3D,CACD,CAKAV,EAAO,QAAUO,IClHjB,IAAIe,EAAO,IAKX,OAAO,QAAUA", + "names": ["require_main", "__commonJSMin", "exports", "module", "setReadOnly", "isFunction", "isIteratorLike", "iteratorSymbol", "noop", "format", "iterPop", "iterator", "clbk", "thisArg", "last", "iter", "FLG", "cb", "i", "next", "end", "factory", "out", "v", "value", "main"] +} diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index 0364887..3f17d2e 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -// TypeScript Version: 2.0 +// TypeScript Version: 4.1 /// diff --git a/package.json b/package.json index e99bf6e..aad21f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stdlib/iter-pop", - "version": "0.0.7", + "version": "0.1.0", "description": "Create an iterator which skips the last value of a provided iterator.", "license": "Apache-2.0", "author": { @@ -37,19 +37,19 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/string-format": "^0.0.3", - "@stdlib/symbol-iterator": "^0.0.7", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-noop": "^0.0.14" + "@stdlib/assert-is-function": "^0.1.0", + "@stdlib/assert-is-iterator-like": "^0.1.0", + "@stdlib/string-format": "^0.1.0", + "@stdlib/symbol-iterator": "^0.1.0", + "@stdlib/types": "^0.1.0", + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", + "@stdlib/utils-noop": "^0.1.0" }, "devDependencies": { "@stdlib/array-to-iterator": "^0.0.6", - "@stdlib/bench": "^0.0.12", + "@stdlib/bench": "^0.1.0", "@stdlib/iter-empty": "^0.0.7", - "@stdlib/math-base-assert-is-nan": "^0.0.8", + "@stdlib/math-base-assert-is-nan": "^0.1.0", "@stdlib/random-iter-randu": "^0.0.6", "proxyquire": "^2.0.0", "tape": "git+https://github.com/kgryte/tape.git#fix/globby",