diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c6cc190..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T04:00:45.060Z 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/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..3bb1442 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3 @@ +/// +import pop from '../docs/types/index'; +export = pop; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..f1ab8e6 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,9 @@ +"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var p=u(function(O,n){ +function y(r){var e,t;return r.length===0?[r,void 0]:(e=r.length-1,t=r[e],delete r[e],r.length=e,[r,t])}n.exports=y +});var v=u(function(E,i){ +function g(r){var e,t,a;return r.length===0?[r,void 0]:(t=r.length-1,a=r[t],e=new r.constructor(r.buffer,r.byteOffset,t),[e,a])}i.exports=g +});var f=u(function(I,s){ +var h=require('@stdlib/assert-is-array/dist'),d=require('@stdlib/assert-is-typed-array-like/dist'),q=require('@stdlib/assert-is-integer/dist'),m=require('@stdlib/error-tools-fmtprodmsg/dist'),w=p(),x=v();function A(r){var e;if(h(r))return e=r.pop(),[r,e];if(d(r))return x(r);if(r!==null&&typeof r=="object"&&typeof r.length=="number"&&q(r.length)&&r.length>=0)return w(r);throw new TypeError(m('1WlBm',r))}s.exports=A +});var T=f();module.exports=T; +/** @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..d19d1c7 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../lib/pop_object.js", "../lib/pop_typed_array.js", "../lib/main.js", "../lib/index.js"], + "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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// MAIN //\n\n/**\n* Removes and returns the last element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = pop( obj );\n* // returns [ { 'length': 1, '0': 1.0 }, 2.0 ]\n*/\nfunction pop( obj ) {\n\tvar len;\n\tvar v;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ len ];\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = pop;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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// MAIN //\n\n/**\n* Removes and returns the last element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = pop( arr );\n* // returns [ [ 1.0, 2.0, 3.0, 4.0 ], 5.0 ]\n*/\nfunction pop( arr ) {\n\tvar view;\n\tvar len;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tlen = arr.length - 1;\n\tv = arr[ len ];\n\tview = new arr.constructor( arr.buffer, arr.byteOffset, len );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = pop;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar popObject = require( './pop_object.js' );\nvar popTypedArray = require( './pop_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the last element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = pop( arr );\n* // returns [ [ 1.0, 2.0, 3.0, 4.0 ], 5.0 ]\n*\n* @example\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = pop( arr );\n* // returns [ [ 1.0, 2.0, 3.0, 4.0 ], 5.0 ]\n*/\nfunction pop( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.pop();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn popTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn popObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = pop;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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* Remove and return the last element of a collection.\n*\n* @module @stdlib/utils-pop\n*\n* @example\n* var pop = require( '@stdlib/utils-pop' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = pop( arr );\n* // returns [ [ 1.0, 2.0, 3.0, 4.0 ], 5.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = pop( arr )\n* // returns [ [ 1.0, 2.0, 3.0, 4.0 ], 5.0 ]\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,cAuCA,SAASC,EAAKC,EAAM,CACnB,IAAIC,EACAC,EACJ,OAAKF,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAKC,CAAI,EACb,OAAOD,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,EACjB,CAKAJ,EAAO,QAAUC,ICvDjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAAKC,EAAM,CACnB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBE,EAAMF,EAAI,OAAS,EACnBG,EAAIH,EAAKE,CAAI,EACbD,EAAO,IAAID,EAAI,YAAaA,EAAI,OAAQA,EAAI,WAAYE,CAAI,EACrD,CAAED,EAAME,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICpDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAY,IACZC,EAAgB,IAyBpB,SAASC,EAAKC,EAAa,CAC1B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,IAAI,EACZ,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAeE,CAAW,EAGlC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAWG,CAAW,EAE9B,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICnCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", + "names": ["require_pop_object", "__commonJSMin", "exports", "module", "pop", "obj", "len", "v", "require_pop_typed_array", "__commonJSMin", "exports", "module", "pop", "arr", "view", "len", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "popObject", "popTypedArray", "pop", "collection", "v", "main"] +} diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index d030e77..cd4158d 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { Collection } from '@stdlib/types/object'; +import { Collection } from '@stdlib/types/array'; /** * Removes and returns the last element of a collection. @@ -49,7 +49,7 @@ import { Collection } from '@stdlib/types/object'; * var out = pop( arr ); * // returns [ [ 1.0, 2.0, 3.0, 4.0 ], 5.0 ] */ -declare function pop( collection: Collection ): [Collection, T]; +declare function pop( collection: Collection ): [Collection, T]; // EXPORTS //