From 9ddd1a63ffd7254dd2fa748478e3a375051538db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 04:32:06 +0000 Subject: [PATCH 001/159] Auto-generated commit 877f1a1493ceb7a0f42b2866d7eb54626fc84d65 --- mod.d.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ mod.js | 4 ++++ mod.js.map | 1 + 3 files changed, 47 insertions(+) create mode 100644 mod.d.ts create mode 100644 mod.js create mode 100644 mod.js.map diff --git a/mod.d.ts b/mod.d.ts new file mode 100644 index 0000000..7ae7765 --- /dev/null +++ b/mod.d.ts @@ -0,0 +1,42 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/** +* Inserts supplied variable values into a format string. +* +* @param str - input string +* @param ...args - variable values +* @throws invalid flags +* @returns formatted string +* +* @example +* var str = format( 'Hello %s!', 'world' ); +* // returns 'Hello world!' +* +* @example +* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); +* // returns 'Pi: ~3.14' +*/ +declare function format( str: string, ...args: Array ): string; + + +// EXPORTS // + +export = format; diff --git a/mod.js b/mod.js new file mode 100644 index 0000000..6f39b24 --- /dev/null +++ b/mod.js @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +var e=function(e){return"number"==typeof e};function r(e){var r,a="";for(r=0;r0&&(r-=1),a=i.toExponential(r)):a=i.toPrecision(e.precision),e.alternate||(a=d.call(a,m,"$1e"),a=d.call(a,v,"e"),a=d.call(a,b,""));break;default:throw new Error("invalid double notation. Value: "+e.specifier)}return a=d.call(a,h,"e+0$1"),a=d.call(a,f,"e-0$1"),e.alternate&&(a=d.call(a,u,"$1."),a=d.call(a,w,"$1.e")),i>=0&&e.sign&&(a=e.sign+a),a=e.specifier===g.call(e.specifier)?g.call(a):l.call(a)},S=function(e){var r,a,i,t;for(a=[],t=0,i=x.exec(e);i;)(r=e.slice(t,x.lastIndex-i[0].length)).length&&a.push(r),a.push(k(i)),t=x.lastIndex,i=x.exec(e);return(r=e.slice(t)).length&&a.push(r),a},F=function(e,r,a){var i=r-e.length;return i<0?e:e=a?e+E(i):E(i)+e},I=a,P=function(e){return"string"==typeof e},V=String.fromCharCode,C=isNaN;var R=function e(r){var a,i,t,n,s,o,c,p,l;if(!P(r))throw new TypeError(e("invalid argument. First argument must be a string. Value: `%s`.",r));for(a=S(r),o="",c=1,p=0;p127)throw new Error("invalid character code. Value: "+t.arg);t.arg=C(s)?String(t.arg):V(s)}break;case"e":case"E":case"f":case"F":case"g":case"G":t.hasPeriod||(t.precision=6),t.arg=$(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=I(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=F(t.arg,t.width,t.padRight)),o+=t.arg||"",c+=1}return o},Z=R;export{Z as default}; +//# sourceMappingURL=mod.js.map diff --git a/mod.js.map b/mod.js.map new file mode 100644 index 0000000..38292d6 --- /dev/null +++ b/mod.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mod.js","sources":["../lib/is_number.js","../lib/zero_pad.js","../lib/format_integer.js","../lib/format_double.js","../lib/tokenize.js","../lib/space_pad.js","../lib/is_string.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( typeof value === 'number' ); // NOTE: we inline the `isNumber.isPrimitive` function from `@stdlib/assert/is-number` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nmodule.exports = isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Tests if a string starts with a minus sign (`-`).\n*\n* @private\n* @param {string} str - input string\n* @returns {boolean} boolean indicating if a string starts with a minus sign (`-`)\n*/\nfunction startsWithMinus( str ) {\n\treturn str[ 0 ] === '-';\n}\n\n/**\n* Returns a string of `n` zeros.\n*\n* @private\n* @param {number} n - number of zeros\n* @returns {string} string of zeros\n*/\nfunction zeros( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += '0';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with zeros to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction zeroPad( str, width, right ) {\n\tvar negative = false;\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tif ( startsWithMinus( str ) ) {\n\t\tnegative = true;\n\t\tstr = str.substr( 1 );\n\t}\n\tstr = ( right ) ?\n\t\tstr + zeros( pad ) :\n\t\tzeros( pad ) + str;\n\tif ( negative ) {\n\t\tstr = '-' + str;\n\t}\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeroPad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 isNumber = require( './is_number.js' );\nvar zeroPad = require( './zero_pad.js' );\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as an integer.\n*\n* @private\n* @param {Object} token - token object\n* @throws {Error} must provide a valid integer\n* @returns {string} formatted token argument\n*/\nfunction formatInteger( token ) {\n\tvar base;\n\tvar out;\n\tvar i;\n\n\tswitch ( token.specifier ) {\n\tcase 'b':\n\t\t// Case: %b (binary)\n\t\tbase = 2;\n\t\tbreak;\n\tcase 'o':\n\t\t// Case: %o (octal)\n\t\tbase = 8;\n\t\tbreak;\n\tcase 'x':\n\tcase 'X':\n\t\t// Case: %x, %X (hexadecimal)\n\t\tbase = 16;\n\t\tbreak;\n\tcase 'd':\n\tcase 'i':\n\tcase 'u':\n\tdefault:\n\t\t// Case: %d, %i, %u (decimal)\n\t\tbase = 10;\n\t\tbreak;\n\t}\n\tout = token.arg;\n\ti = parseInt( out, 10 );\n\tif ( !isFinite( i ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\tif ( !isNumber( out ) ) {\n\t\t\tthrow new Error( 'invalid integer. Value: ' + out );\n\t\t}\n\t\ti = 0;\n\t}\n\tif ( i < 0 && ( token.specifier === 'u' || base !== 10 ) ) {\n\t\ti = 0xffffffff + i + 1;\n\t}\n\tif ( i < 0 ) {\n\t\tout = ( -i ).toString( base );\n\t\tif ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tout = '-' + out;\n\t} else {\n\t\tout = i.toString( base );\n\t\tif ( !i && !token.precision ) {\n\t\t\tout = '';\n\t\t} else if ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tif ( token.sign ) {\n\t\t\tout = token.sign + out;\n\t\t}\n\t}\n\tif ( base === 16 ) {\n\t\tif ( token.alternate ) {\n\t\t\tout = '0x' + out;\n\t\t}\n\t\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\t\tuppercase.call( out ) :\n\t\t\tlowercase.call( out );\n\t}\n\tif ( base === 8 ) {\n\t\tif ( token.alternate && out.charAt( 0 ) !== '0' ) {\n\t\t\tout = '0' + out;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 isNumber = require( './is_number.js' );\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar abs = Math.abs; // eslint-disable-line stdlib/no-builtin-math\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\nvar replace = String.prototype.replace;\n\n\n// VARIABLES //\n\nvar RE_EXP_POS_DIGITS = /e\\+(\\d)$/;\nvar RE_EXP_NEG_DIGITS = /e-(\\d)$/;\nvar RE_ONLY_DIGITS = /^(\\d+)$/;\nvar RE_DIGITS_BEFORE_EXP = /^(\\d+)e/;\nvar RE_TRAILING_PERIOD_ZERO = /\\.0$/;\nvar RE_PERIOD_ZERO_EXP = /\\.0*e/;\nvar RE_ZERO_BEFORE_EXP = /(\\..*[^0])0*e/;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as a floating-point number.\n*\n* @private\n* @param {Object} token - token object\n* @throws {Error} must provide a valid floating-point number\n* @returns {string} formatted token argument\n*/\nfunction formatDouble( token ) {\n\tvar digits;\n\tvar out;\n\tvar f = parseFloat( token.arg );\n\tif ( !isFinite( f ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\tif ( !isNumber( token.arg ) ) {\n\t\t\tthrow new Error( 'invalid floating-point number. Value: ' + out );\n\t\t}\n\t\t// Case: NaN, Infinity, or -Infinity\n\t\tf = token.arg;\n\t}\n\tswitch ( token.specifier ) {\n\tcase 'e':\n\tcase 'E':\n\t\tout = f.toExponential( token.precision );\n\t\tbreak;\n\tcase 'f':\n\tcase 'F':\n\t\tout = f.toFixed( token.precision );\n\t\tbreak;\n\tcase 'g':\n\tcase 'G':\n\t\tif ( abs( f ) < 0.0001 ) {\n\t\t\tdigits = token.precision;\n\t\t\tif ( digits > 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\treturn {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'hasPeriod': match[ 4 ] === '.',\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string.\n*\n* @private\n* @param {string} str - input string\n* @returns {Array} tokens\n*/\nfunction tokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nmodule.exports = tokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nmodule.exports = isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 formatInteger = require( './format_integer.js' );\nvar formatDouble = require( './format_double.js' );\nvar tokenize = require( './tokenize.js' );\nvar spacePad = require( './space_pad.js' );\nvar zeroPad = require( './zero_pad.js' );\nvar isString = require( './is_string.js' );\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );\n\t}\n\ttokens = tokenize( str );\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.precision === '*' && token.hasPeriod ) {\n\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\ttoken.hasPeriod = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( token.hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( token.hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !token.hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Insert supplied variable values into a format string.\n*\n* @module @stdlib/string-format\n*\n* @example\n* var format = require( '@stdlib/string-format' );\n*\n* var out = format( '%s %s!', 'Hello', 'World' );\n* // returns 'Hello World!'\n*\n* out = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\n\n// MODULES //\n\nvar format = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = format;\n"],"names":["is_number","value","zeros","n","i","out","zero_pad","str","width","right","negative","pad","length","startsWithMinus","substr","isNumber","require$$0","zeroPad","require$$1","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","format_integer","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","RE","parse","match","mapping","flags","hasPeriod","spaces","formatInteger","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","tokenize","content","tokens","prev","exec","slice","lastIndex","push","spacePad","require$$4","isString","fromCharCode","isnan","isNaN","main","format","flag","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AMQ,UAAWR,EAAMS,UAC3DT,EAAMlB,QACjBkB,EAAMG,IAAM4C,EAAU/C,EAAMG,IAAKH,EAAMlB,MAAOkB,EAAMS,WAErD9B,GAAOqB,EAAMG,KAAO,GACpBsD,GAAO,EAGT,OAAO9E,GC/IRsF,EALa3E"} \ No newline at end of file From 97fbf3e1181430c216c2b4a3f9a3812e44533975 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jun 2022 01:01:59 +0000 Subject: [PATCH 002/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/bundle.yml | 504 ---- .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 160 -- .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/index.d.ts | 42 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - mod.js | 2 +- mod.js.map | 2 +- package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 39 files changed, 2697 insertions(+), 4437 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/bundle.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5e5b58a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-01T00:31:58.583Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml deleted file mode 100644 index 10f472a..0000000 --- a/.github/workflows/bundle.yml +++ /dev/null @@ -1,504 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: bundle - -# Workflow triggers: -on: - # Allow workflow to be manually run: - workflow_dispatch: - - # Run workflow upon completion of `productionize` workflow: - workflow_run: - workflows: ["productionize"] - types: [completed] - -# Workflow jobs: -jobs: - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Checkout production branch: - - name: 'Checkout production branch' - run: | - git fetch --all - git checkout -b production origin/production - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, checkout branch and rebase on `main`: - - name: 'If `deno` exists, checkout branch and rebase on `main`' - if: steps.deno-branch-exists.outputs.remote-exists - continue-on-error: true - run: | - git checkout -b deno origin/deno - git rebase main -s recursive -X ours - while [ $? -ne 0 ]; do - git rebase --skip - done - - # If `deno` does not exist, checkout `main` and create `deno` branch: - - name: 'If `deno` does not exist, checkout `main` and create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout main - git checkout -b deno - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno --force - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Checkout production branch: - - name: 'Checkout production branch' - run: | - git fetch --all - git checkout -b production origin/production - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 0fd7e6e3f884f11194f057bc802d52402a68d638 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 21:04:13 +0000 Subject: [PATCH 003/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index 4e14c75..f984d98 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.1", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From f8b7a12e184a7eeab9947126a780f2f96216a151 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 08:00:26 +0000 Subject: [PATCH 004/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 00e2919..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -var e=function(e){return"number"==typeof e};function r(e){var r,i="";for(r=0;r0&&(r-=1),i=a.toExponential(r)):i=a.toPrecision(e.precision),e.alternate||(i=u.call(i,y,"$1e"),i=u.call(i,m,"e"),i=u.call(i,b,""));break;default:throw new Error("invalid double notation. Value: "+e.specifier)}return i=u.call(i,d,"e+0$1"),i=u.call(i,h,"e-0$1"),e.alternate&&(i=u.call(i,w,"$1."),i=u.call(i,v,"$1.e")),a>=0&&e.sign&&(i=e.sign+i),i=e.specifier===f.call(e.specifier)?f.call(i):g.call(i)},S=function(e,r,i){var a=r-e.length;return a<0?e:e=i?e+x(a):x(a)+e},I=i,V=String.fromCharCode,F=isNaN,R=Array.isArray;function A(e){var r={};return r.specifier=e.specifier,r.precision=void 0===e.precision?1:e.precision,r.width=e.width,r.flags=e.flags||"",r.mapping=e.mapping,r}var C=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function T(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}var Z=function(e){var r,i,a,t,n,s,o,c,p;if(!R(e))throw new TypeError("invalid argument. First argument must be an array. Value: `"+e+"`.");for(s="",o=1,c=0;c127)throw new Error("invalid character code. Value: "+a.arg);a.arg=F(n)?String(a.arg):V(n)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(a.precision=6),a.arg=$(a);break;default:throw new Error("invalid specifier: "+a.specifier)}a.maxWidth>=0&&a.arg.length>a.maxWidth&&(a.arg=a.arg.substring(0,a.maxWidth)),a.padZeros?a.arg=I(a.arg,a.width||a.precision,a.padRight):a.width&&(a.arg=S(a.arg,a.width,a.padRight)),s+=a.arg||"",o+=1}return s},W=function(e){var r,i,a,t;for(i=[],t=0,a=C.exec(e);a;)(r=e.slice(t,C.lastIndex-a[0].length)).length&&i.push(r),i.push(T(a)),t=C.lastIndex,a=C.exec(e);return(r=e.slice(t)).length&&i.push(r),i},L=function(e){return"string"==typeof e};var G=function e(r){var i,a,t;if(!L(r))throw new TypeError(e("0hB3R",r));for(i=W(r),(a=new Array(arguments.length))[0]=i,t=1;t 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 formatInteger = require( './format_integer.js' );\nvar isString = require( './is_string.js' );\nvar formatDouble = require( './format_double.js' );\nvar spacePad = require( './space_pad.js' );\nvar zeroPad = require( './zero_pad.js' );\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nmodule.exports = isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 interpolate = require( '@stdlib/string-base-format-interpolate' );\nvar tokenize = require( '@stdlib/string-base-format-tokenize' );\nvar isString = require( './is_string.js' );\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nmodule.exports = format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Insert supplied variable values into a format string.\n*\n* @module @stdlib/string-format\n*\n* @example\n* var format = require( '@stdlib/string-format' );\n*\n* var out = format( '%s %s!', 'Hello', 'World' );\n* // returns 'Hello World!'\n*\n* out = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\n\n// MODULES //\n\nvar format = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = format;\n"],"names":["is_number","value","zeros","n","i","out","zero_pad","str","width","right","negative","pad","length","startsWithMinus","substr","isNumber","require$$0","zeroPad","require$$1","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","format_integer","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","is_string","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","spaces","formatInteger","isString","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spacePad","require$$4","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","RE","parse","match","interpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","tokenize","content","prev","exec","slice","lastIndex","push","main","format","args","apply","lib"],"mappings":";;AA6CA,IAAAA,EAPA,SAAmBC,GAClB,MAA0B,iBAAVA,GCCjB,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,EAqCR,IAAAC,EAtBA,SAAkBC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,GAqCPM,CAAiBN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EAAOkB,KAAML,GAEdb,EAAOkB,KAAMrB,EAAOC,IACpBgB,EAAOlB,EAAGqB,UACVnB,EAAQF,EAAGmB,KAAMnF,GAMlB,OAJAiF,EAAUjF,EAAIoF,MAAOF,IACR7E,QACZ+D,EAAOkB,KAAML,GAEPb,GE3DJtB,EDUJ,SAAmBpD,GAClB,MAA0B,iBAAVA,GC+BjB,IAAA6F,EApBA,SAASC,EAAQxF,GAChB,IAAIoE,EACAqB,EACA5F,EAEJ,IAAMiD,EAAU9C,GACf,MAAM,IAAI0E,UAAWc,EAAQ,QAASxF,IAKvC,IAHAoE,EAASY,EAAUhF,IACnByF,EAAO,IAAI7B,MAAOiB,UAAUxE,SACtB,GAAM+D,EACNvE,EAAI,EAAGA,EAAI4F,EAAKpF,OAAQR,IAC7B4F,EAAM5F,GAAMgF,UAAWhF,GAExB,OAAOsE,EAAYuB,MAAO,KAAMD,IClBjCE,EALalF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 863bd5a..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0b23b3c031163a931802d0b32833b5de3b36be45 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 08:01:04 +0000 Subject: [PATCH 005/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 38 files changed, 2699 insertions(+), 4409 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 90d7edd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:03:28.671Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From d125fcc1d77ce99d17f268148aabd5adde734de8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 17:09:29 +0000 Subject: [PATCH 006/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index 4e14c75..f984d98 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.1", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From f09a8ae1c2b8ba7b659e72741289253784066bff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 04:26:26 +0000 Subject: [PATCH 007/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 7bd7dac..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -var e=function(e){return"number"==typeof e};function r(e){var r,i="";for(r=0;r0&&(r-=1),i=a.toExponential(r)):i=a.toPrecision(e.precision),e.alternate||(i=u.call(i,y,"$1e"),i=u.call(i,m,"e"),i=u.call(i,b,""));break;default:throw new Error("invalid double notation. Value: "+e.specifier)}return i=u.call(i,d,"e+0$1"),i=u.call(i,h,"e-0$1"),e.alternate&&(i=u.call(i,w,"$1."),i=u.call(i,v,"$1.e")),a>=0&&e.sign&&(i=e.sign+i),i=e.specifier===f.call(e.specifier)?f.call(i):g.call(i)},S=function(e,r,i){var a=r-e.length;return a<0?e:e=i?e+x(a):x(a)+e},I=i,V=String.fromCharCode,F=isNaN,R=Array.isArray;function A(e){var r={};return r.specifier=e.specifier,r.precision=void 0===e.precision?1:e.precision,r.width=e.width,r.flags=e.flags||"",r.mapping=e.mapping,r}var C=function(e){var r,i,a,t,n,s,o,c,p;if(!R(e))throw new TypeError("invalid argument. First argument must be an array. Value: `"+e+"`.");for(s="",o=1,c=0;c127)throw new Error("invalid character code. Value: "+a.arg);a.arg=F(n)?String(a.arg):V(n)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(a.precision=6),a.arg=$(a);break;default:throw new Error("invalid specifier: "+a.specifier)}a.maxWidth>=0&&a.arg.length>a.maxWidth&&(a.arg=a.arg.substring(0,a.maxWidth)),a.padZeros?a.arg=I(a.arg,a.width||a.precision,a.padRight):a.width&&(a.arg=S(a.arg,a.width,a.padRight)),s+=a.arg||"",o+=1}return s},T=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function Z(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}var W=function(e){var r,i,a,t;for(i=[],t=0,a=T.exec(e);a;)(r=e.slice(t,T.lastIndex-a[0].length)).length&&i.push(r),i.push(Z(a)),t=T.lastIndex,a=T.exec(e);return(r=e.slice(t)).length&&i.push(r),i};function L(e){return"string"==typeof e}function G(e){var r,i,a;if(!L(e))throw new TypeError(G("0hB3R",e));for(r=W(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 formatInteger = require( './format_integer.js' );\nvar isString = require( './is_string.js' );\nvar formatDouble = require( './format_double.js' );\nvar spacePad = require( './space_pad.js' );\nvar zeroPad = require( './zero_pad.js' );\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Generate string from a token array by interpolating values.\n*\n* @module @stdlib/string-base-format-interpolate\n*\n* @example\n* var formatInterpolate = require( '@stdlib/string-base-format-interpolate' );\n*\n* var tokens = ['Hello ', { 'specifier': 's' }, '!' ];\n* var out = formatInterpolate( tokens, 'World' );\n* // returns 'Hello World!'\n*/\n\n// MODULES //\n\nvar formatInterpolate = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tokenize a string into an array of string parts and format identifier objects.\n*\n* @module @stdlib/string-base-format-tokenize\n*\n* @example\n* var formatTokenize = require( '@stdlib/string-base-format-tokenize' );\n*\n* var str = 'Hello %s!';\n* var tokens = formatTokenize( str );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\n\n// MODULES //\n\nvar formatTokenize = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["is_number","value","zeros","n","i","out","zero_pad","str","width","right","negative","pad","length","startsWithMinus","substr","isNumber","require$$0","zeroPad","require$$1","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","format_integer","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","is_string","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","spaces","formatInteger","isString","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spacePad","require$$4","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","lib","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AA6CA,IAAAA,EAPA,SAAmBC,GAClB,MAA0B,iBAAVA,GCCjB,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,E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A4CR,ICjDA6C,EDqBA,SAAyBhE,GACxB,IAAIgF,EACAf,EACAc,EACAE,EAKJ,IAHAhB,EAAS,GACTgB,EAAO,EACPF,EAAQF,EAAGK,KAAMlF,GACT+E,IACPC,EAAUhF,EAAImF,MAAOF,EAAMJ,EAAGO,UAAYL,EAAO,GAAI1E,SACxCA,QACZ4D,EAAOoB,KAAML,GAEdf,EAAOoB,KAAMP,EAAOC,IACpBE,EAAOJ,EAAGO,UACVL,EAAQF,EAAGK,KAAMlF,GAMlB,OAJAgF,EAAUhF,EAAImF,MAAOF,IACR5E,QACZ4D,EAAOoB,KAAML,GAEPf,GEjDR,SAASnB,EAAUpD,GAClB,MAA0B,iBAAVA,ECWjB,SAAS4F,EAAQtF,GAChB,IAAIiE,EACAsB,EACA1F,EAEJ,IAAMiD,EAAU9C,GACf,MAAM,IAAIuE,UAAWe,EAAQ,QAAStF,IAKvC,IAHAiE,EAASuB,EAAUxF,IACnBuF,EAAO,IAAI3B,MAAOc,UAAUrE,SACtB,GAAM4D,EACNpE,EAAI,EAAGA,EAAI0F,EAAKlF,OAAQR,IAC7B0F,EAAM1F,GAAM6E,UAAW7E,GAExB,OAAO4F,EAAYC,MAAO,KAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 442d69d..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 4f525bf3295ece988a0be52f0cd6753dcd12425e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 04:27:06 +0000 Subject: [PATCH 008/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 38 files changed, 2699 insertions(+), 4409 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b92b99e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T00:32:40.853Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From ed814ad7b6a87ed673d5ebe8b4a690cfd0c5cc2f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 3 Jul 2022 00:25:51 +0000 Subject: [PATCH 009/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index 87fba20..aab78a5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.2", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From c26dfc1b2b032d7d4a6f34affe01b7d8cdf48b1f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 3 Jul 2022 00:27:35 +0000 Subject: [PATCH 010/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 7bd7dac..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -var e=function(e){return"number"==typeof e};function r(e){var r,i="";for(r=0;r0&&(r-=1),i=a.toExponential(r)):i=a.toPrecision(e.precision),e.alternate||(i=u.call(i,y,"$1e"),i=u.call(i,m,"e"),i=u.call(i,b,""));break;default:throw new Error("invalid double notation. Value: "+e.specifier)}return i=u.call(i,d,"e+0$1"),i=u.call(i,h,"e-0$1"),e.alternate&&(i=u.call(i,w,"$1."),i=u.call(i,v,"$1.e")),a>=0&&e.sign&&(i=e.sign+i),i=e.specifier===f.call(e.specifier)?f.call(i):g.call(i)},S=function(e,r,i){var a=r-e.length;return a<0?e:e=i?e+x(a):x(a)+e},I=i,V=String.fromCharCode,F=isNaN,R=Array.isArray;function A(e){var r={};return r.specifier=e.specifier,r.precision=void 0===e.precision?1:e.precision,r.width=e.width,r.flags=e.flags||"",r.mapping=e.mapping,r}var C=function(e){var r,i,a,t,n,s,o,c,p;if(!R(e))throw new TypeError("invalid argument. First argument must be an array. Value: `"+e+"`.");for(s="",o=1,c=0;c127)throw new Error("invalid character code. Value: "+a.arg);a.arg=F(n)?String(a.arg):V(n)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(a.precision=6),a.arg=$(a);break;default:throw new Error("invalid specifier: "+a.specifier)}a.maxWidth>=0&&a.arg.length>a.maxWidth&&(a.arg=a.arg.substring(0,a.maxWidth)),a.padZeros?a.arg=I(a.arg,a.width||a.precision,a.padRight):a.width&&(a.arg=S(a.arg,a.width,a.padRight)),s+=a.arg||"",o+=1}return s},T=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function Z(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}var W=function(e){var r,i,a,t;for(i=[],t=0,a=T.exec(e);a;)(r=e.slice(t,T.lastIndex-a[0].length)).length&&i.push(r),i.push(Z(a)),t=T.lastIndex,a=T.exec(e);return(r=e.slice(t)).length&&i.push(r),i};function L(e){return"string"==typeof e}function G(e){var r,i,a;if(!L(e))throw new TypeError(G("0hB3R",e));for(r=W(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 formatInteger = require( './format_integer.js' );\nvar isString = require( './is_string.js' );\nvar formatDouble = require( './format_double.js' );\nvar spacePad = require( './space_pad.js' );\nvar zeroPad = require( './zero_pad.js' );\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Generate string from a token array by interpolating values.\n*\n* @module @stdlib/string-base-format-interpolate\n*\n* @example\n* var formatInterpolate = require( '@stdlib/string-base-format-interpolate' );\n*\n* var tokens = ['Hello ', { 'specifier': 's' }, '!' ];\n* var out = formatInterpolate( tokens, 'World' );\n* // returns 'Hello World!'\n*/\n\n// MODULES //\n\nvar formatInterpolate = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tokenize a string into an array of string parts and format identifier objects.\n*\n* @module @stdlib/string-base-format-tokenize\n*\n* @example\n* var formatTokenize = require( '@stdlib/string-base-format-tokenize' );\n*\n* var str = 'Hello %s!';\n* var tokens = formatTokenize( str );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\n\n// MODULES //\n\nvar formatTokenize = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["is_number","value","zeros","n","i","out","zero_pad","str","width","right","negative","pad","length","startsWithMinus","substr","isNumber","require$$0","zeroPad","require$$1","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","format_integer","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","is_string","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","spaces","formatInteger","isString","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spacePad","require$$4","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","lib","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AA6CA,IAAAA,EAPA,SAAmBC,GAClB,MAA0B,iBAAVA,GCCjB,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,EAqCR,IAAAC,EAtBA,SAAkBC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,GAqCPM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,GC3CLQ,EAAWC,EACXC,EAAUC,EAGVC,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAuFjC,IAAAC,EA1EA,SAAwBC,GACvB,IAAIC,EACAtB,EACAD,EAEJ,OAASsB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAtB,EAAMqB,EAAMG,IACZzB,EAAI0B,SAAUzB,EAAK,KACb0B,SAAU3B,GAAM,CACrB,IAAMW,EAAUV,GACf,MAAM,IAAI2B,MAAO,2BAA6B3B,GAE/CD,EAAI,EAmCL,OAjCKA,EAAI,IAA2B,MAApBsB,EAAME,WAA8B,KAATD,KAC1CvB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAI6B,SAAUN,GAClBD,EAAMQ,YACV7B,EAAMY,EAASZ,EAAKqB,EAAMQ,UAAWR,EAAMS,WAE5C9B,EAAM,IAAMA,IAEZA,EAAMD,EAAE6B,SAAUN,GACZvB,GAAMsB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AAUwD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChB9E,MAAS8E,EAAO,GAChBpD,UAAaoD,EAAO,GACpB1D,UAAa0D,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjC5D,EAAMQ,UAAY,KAEZR,EA4CR,ICjDA6C,EDqBA,SAAyBhE,GACxB,IAAIgF,EACAf,EACAc,EACAE,EAKJ,IAHAhB,EAAS,GACTgB,EAAO,EACPF,EAAQF,EAAGK,KAAMlF,GACT+E,IACPC,EAAUhF,EAAImF,MAAOF,EAAMJ,EAAGO,UAAYL,EAAO,GAAI1E,SACxCA,QACZ4D,EAAOoB,KAAML,GAEdf,EAAOoB,KAAMP,EAAOC,IACpBE,EAAOJ,EAAGO,UACVL,EAAQF,EAAGK,KAAMlF,GAMlB,OAJAgF,EAAUhF,EAAImF,MAAOF,IACR5E,QACZ4D,EAAOoB,KAAML,GAEPf,GEjDR,SAASnB,EAAUpD,GAClB,MAA0B,iBAAVA,ECWjB,SAAS4F,EAAQtF,GAChB,IAAIiE,EACAsB,EACA1F,EAEJ,IAAMiD,EAAU9C,GACf,MAAM,IAAIuE,UAAWe,EAAQ,QAAStF,IAKvC,IAHAiE,EAASuB,EAAUxF,IACnBuF,EAAO,IAAI3B,MAAOc,UAAUrE,SACtB,GAAM4D,EACNpE,EAAI,EAAGA,EAAI0F,EAAKlF,OAAQR,IAC7B0F,EAAM1F,GAAM6E,UAAW7E,GAExB,OAAO4F,EAAYC,MAAO,KAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4911529..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 5591a52381f5ae2b1540e55a3625c7d5949b5d4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 3 Jul 2022 00:28:07 +0000 Subject: [PATCH 011/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 37 files changed, 2699 insertions(+), 4408 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 632774b1f63ccbe72232a4cc852c145696558de2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 3 Jul 2022 13:30:49 +0000 Subject: [PATCH 012/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index 87fba20..aab78a5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.2", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From b5e85174f117f87b4998d672198b7e41ae1045f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 3 Jul 2022 13:32:06 +0000 Subject: [PATCH 013/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 7bd7dac..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -var e=function(e){return"number"==typeof e};function r(e){var r,i="";for(r=0;r0&&(r-=1),i=a.toExponential(r)):i=a.toPrecision(e.precision),e.alternate||(i=u.call(i,y,"$1e"),i=u.call(i,m,"e"),i=u.call(i,b,""));break;default:throw new Error("invalid double notation. Value: "+e.specifier)}return i=u.call(i,d,"e+0$1"),i=u.call(i,h,"e-0$1"),e.alternate&&(i=u.call(i,w,"$1."),i=u.call(i,v,"$1.e")),a>=0&&e.sign&&(i=e.sign+i),i=e.specifier===f.call(e.specifier)?f.call(i):g.call(i)},S=function(e,r,i){var a=r-e.length;return a<0?e:e=i?e+x(a):x(a)+e},I=i,V=String.fromCharCode,F=isNaN,R=Array.isArray;function A(e){var r={};return r.specifier=e.specifier,r.precision=void 0===e.precision?1:e.precision,r.width=e.width,r.flags=e.flags||"",r.mapping=e.mapping,r}var C=function(e){var r,i,a,t,n,s,o,c,p;if(!R(e))throw new TypeError("invalid argument. First argument must be an array. Value: `"+e+"`.");for(s="",o=1,c=0;c127)throw new Error("invalid character code. Value: "+a.arg);a.arg=F(n)?String(a.arg):V(n)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(a.precision=6),a.arg=$(a);break;default:throw new Error("invalid specifier: "+a.specifier)}a.maxWidth>=0&&a.arg.length>a.maxWidth&&(a.arg=a.arg.substring(0,a.maxWidth)),a.padZeros?a.arg=I(a.arg,a.width||a.precision,a.padRight):a.width&&(a.arg=S(a.arg,a.width,a.padRight)),s+=a.arg||"",o+=1}return s},T=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function Z(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}var W=function(e){var r,i,a,t;for(i=[],t=0,a=T.exec(e);a;)(r=e.slice(t,T.lastIndex-a[0].length)).length&&i.push(r),i.push(Z(a)),t=T.lastIndex,a=T.exec(e);return(r=e.slice(t)).length&&i.push(r),i};function L(e){return"string"==typeof e}function G(e){var r,i,a;if(!L(e))throw new TypeError(G("0hB3R",e));for(r=W(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 formatInteger = require( './format_integer.js' );\nvar isString = require( './is_string.js' );\nvar formatDouble = require( './format_double.js' );\nvar spacePad = require( './space_pad.js' );\nvar zeroPad = require( './zero_pad.js' );\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Generate string from a token array by interpolating values.\n*\n* @module @stdlib/string-base-format-interpolate\n*\n* @example\n* var formatInterpolate = require( '@stdlib/string-base-format-interpolate' );\n*\n* var tokens = ['Hello ', { 'specifier': 's' }, '!' ];\n* var out = formatInterpolate( tokens, 'World' );\n* // returns 'Hello World!'\n*/\n\n// MODULES //\n\nvar formatInterpolate = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nmodule.exports = formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tokenize a string into an array of string parts and format identifier objects.\n*\n* @module @stdlib/string-base-format-tokenize\n*\n* @example\n* var formatTokenize = require( '@stdlib/string-base-format-tokenize' );\n*\n* var str = 'Hello %s!';\n* var tokens = formatTokenize( str );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\n\n// MODULES //\n\nvar formatTokenize = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["is_number","value","zeros","n","i","out","zero_pad","str","width","right","negative","pad","length","startsWithMinus","substr","isNumber","require$$0","zeroPad","require$$1","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","format_integer","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","is_string","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","spaces","formatInteger","isString","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spacePad","require$$4","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","lib","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AA6CA,IAAAA,EAPA,SAAmBC,GAClB,MAA0B,iBAAVA,GCCjB,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,EAqCR,IAAAC,EAtBA,SAAkBC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,GAqCPM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,GC3CLQ,EAAWC,EACXC,EAAUC,EAGVC,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAuFjC,IAAAC,EA1EA,SAAwBC,GACvB,IAAIC,EACAtB,EACAD,EAEJ,OAASsB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAtB,EAAMqB,EAAMG,IACZzB,EAAI0B,SAAUzB,EAAK,KACb0B,SAAU3B,GAAM,CACrB,IAAMW,EAAUV,GACf,MAAM,IAAI2B,MAAO,2BAA6B3B,GAE/CD,EAAI,EAmCL,OAjCKA,EAAI,IAA2B,MAApBsB,EAAME,WAA8B,KAATD,KAC1CvB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAI6B,SAAUN,GAClBD,EAAMQ,YACV7B,EAAMY,EAASZ,EAAKqB,EAAMQ,UAAWR,EAAMS,WAE5C9B,EAAM,IAAMA,IAEZA,EAAMD,E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ACX4C,QAAagB,EAAO,GAAQxD,SAAUwD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChB9E,MAAS8E,EAAO,GAChBpD,UAAaoD,EAAO,GACpB1D,UAAa0D,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjC5D,EAAMQ,UAAY,KAEZR,EA4CR,ICjDA6C,EDqBA,SAAyBhE,GACxB,IAAIgF,EACAf,EACAc,EACAE,EAKJ,IAHAhB,EAAS,GACTgB,EAAO,EACPF,EAAQF,EAAGK,KAAMlF,GACT+E,IACPC,EAAUhF,EAAImF,MAAOF,EAAMJ,EAAGO,UAAYL,EAAO,GAAI1E,SACxCA,QACZ4D,EAAOoB,KAAML,GAEdf,EAAOoB,KAAMP,EAAOC,IACpBE,EAAOJ,EAAGO,UACVL,EAAQF,EAAGK,KAAMlF,GAMlB,OAJAgF,EAAUhF,EAAImF,MAAOF,IACR5E,QACZ4D,EAAOoB,KAAML,GAEPf,GEjDR,SAASnB,EAAUpD,GAClB,MAA0B,iBAAVA,ECWjB,SAAS4F,EAAQtF,GAChB,IAAIiE,EACAsB,EACA1F,EAEJ,IAAMiD,EAAU9C,GACf,MAAM,IAAIuE,UAAWe,EAAQ,QAAStF,IAKvC,IAHAiE,EAASuB,EAAUxF,IACnBuF,EAAO,IAAI3B,MAAOc,UAAUrE,SACtB,GAAM4D,EACNpE,EAAI,EAAGA,EAAI0F,EAAKlF,OAAQR,IAC7B0F,EAAM1F,GAAM6E,UAAW7E,GAExB,OAAO4F,EAAYC,MAAO,KAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8bb0eb0..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 6a60d7a86f9e1eb3b6e554dffd67f9676d37279e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 3 Jul 2022 13:32:36 +0000 Subject: [PATCH 014/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 37 files changed, 2699 insertions(+), 4374 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 6726965..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,687 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From df565a15bc1456afdaf3c32485477a0c722eb0e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Jul 2022 14:15:42 +0000 Subject: [PATCH 015/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index e8860dc..4875ff8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From b422727d10f5dbe07e6fa89a21ef0136c6c71aef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Jul 2022 14:33:19 +0000 Subject: [PATCH 016/159] Update README.md for Deno bundle v0.0.3 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2108c5e..d20542b 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ limitations under the License. ## Usage ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.0.3-deno/mod.js'; ``` #### format( str, ...args ) @@ -215,7 +215,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.0.3-deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From 6257739f6d52e46aa59ac67aa5941d5725a09c68 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Jul 2022 14:33:20 +0000 Subject: [PATCH 017/159] Revert changes to README.md for Deno bundle v0.0.3 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d20542b..2108c5e 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ limitations under the License. ## Usage ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.0.3-deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; ``` #### format( str, ...args ) @@ -215,7 +215,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.0.3-deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From 2cdd440d3cd30c40c53a2770eb3f7baac8ed1019 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Jul 2022 14:41:42 +0000 Subject: [PATCH 018/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 5be49a6..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js' ;\nimport isString from './is_string.js' ;\nimport formatDouble from './format_double.js' ;\nimport spacePad from './space_pad.js' ;\nimport zeroPad from './zero_pad.js' ;\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastI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AAS0D,EAAgBzE,GACxB,IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,ECjDR,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,ECWjB,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1cf5cea..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 85fbfb68d52ffeef7992adac836b62691e72ff92 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Jul 2022 14:42:12 +0000 Subject: [PATCH 019/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/bundle_tags.yml | 125 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 691 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 38 files changed, 2699 insertions(+), 4503 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/bundle_tags.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/bundle_tags.yml b/.github/workflows/bundle_tags.yml deleted file mode 100644 index 46a96ae..0000000 --- a/.github/workflows/bundle_tags.yml +++ /dev/null @@ -1,125 +0,0 @@ - -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: bundle_tags - -# Workflow triggers: -on: - # Run workflow when a new tag is pushed to the repository: - push: - tags: - - '*' - -# Workflow jobs: -jobs: - - # Define job to wait a minute before running the workflow... - waiting: - - # Define display name: - name: 'Waiting Period' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the steps to run: - steps: - - # Wait three minutes: - - name: 'Wait three minutes' - run: | - sleep 3m - - # Define job to publish bundle tags to GitHub... - create-tags: - - # Define display name: - name: 'Create bundle tags' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: waiting - - # Define the steps to run: - steps: - - # Wait for the productionize workflow to succeed: - - name: 'Wait for productionize workflow to succeed' - uses: lewagon/wait-on-check-action@v1.0.0 - timeout-minutes: 5 - with: - ref: main - check-regexp: 'Productionize' - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 60 - allowed-conclusions: success - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - git fetch --all - - # Create bundle tags: - - name: 'Create bundle tags' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - ESCAPED=$(echo $SLUG | sed -E 's/\//\\\//g') - - git checkout -b deno origin/deno - sed -i -E "s/$ESCAPED@deno/$ESCAPED@$VERSION-deno/g" README.md - git add README.md - git commit -m "Update README.md for Deno bundle $VERSION" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - sed -i -E "s/$ESCAPED@$VERSION-deno/$ESCAPED@deno/g" README.md - git add README.md - git commit -m "Revert changes to README.md for Deno bundle $VERSION" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - git checkout -b umd origin/umd - sed -i -E "s/$ESCAPED@umd/$ESCAPED@$VERSION-umd/g" README.md - git add README.md - git commit -m "Update README.md for UMD bundle $VERSION" - git tag -a $VERSION-umd -m "$VERSION-umd" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-umd - sed -i -E "s/$ESCAPED@$VERSION-umd/$ESCAPED@umd/g" README.md - git add README.md - git commit -m "Revert changes to README.md for UMD bundle $VERSION" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd - - git checkout -b esm origin/esm - sed -i -E "s/$ESCAPED@esm/$ESCAPED@$VERSION-esm/g" README.md - git add README.md - git commit -m "Update README.md for ESM bundle $VERSION" - git tag -a $VERSION-esm -m "$VERSION-esm" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-esm - sed -i -E "s/$ESCAPED@$VERSION-esm/$ESCAPED@esm/g" README.md - git add README.md - git commit -m "Revert changes to README.md for ESM bundle $VERSION" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 0a144b2..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,691 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 82df96ea386b092b54422dfba449d85fa59dcf65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 04:41:24 +0000 Subject: [PATCH 020/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index e8860dc..4875ff8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From af1b93424774c874e739de2c8225556d6bd8553a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 19:45:38 +0000 Subject: [PATCH 021/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 5be49a6..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js' ;\nimport isString from './is_string.js' ;\nimport formatDouble from './format_double.js' ;\nimport spacePad from './space_pad.js' ;\nimport zeroPad from './zero_pad.js' ;\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,ECCjB,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,EAeR,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,GAqCPM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,ECvCT,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACA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I5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3009e87..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 468157206162a3e71aaf3135af061c30a225374b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 19:46:19 +0000 Subject: [PATCH 022/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 38 files changed, 2699 insertions(+), 4448 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3c15eb7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T00:36:11.351Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 480db38be719756266f7d0ea0dd2e84b6b4022d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 04:18:25 +0000 Subject: [PATCH 023/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index e8860dc..4875ff8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From 429ea7410eea93cd974ba0a2d48606a43286620b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 15:19:20 +0000 Subject: [PATCH 024/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 5be49a6..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js' ;\nimport isString from './is_string.js' ;\nimport formatDouble from './format_double.js' ;\nimport spacePad from './space_pad.js' ;\nimport zeroPad from './zero_pad.js' ;\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,ECCjB,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,EAeR,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,GAqCPM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,ECvCT,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,EAmCL,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WA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,EAGT,OAAOhE,EC1LR,IAAIwE,EAAK,6EAYT,SAASC,EAAOC,GACf,IAAIzD,EAAQ,CACXyC,QAAagB,EAAO,GAAQrD,SAAUqD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBvE,MAASuE,EAAO,GAChBjD,UAAaiD,EAAO,GACpBvD,UAAauD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCzD,EAAMQ,UAAY,KAEZR,EAgBR,SAAS0D,EAAgBzE,GACxB,IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,ECjDR,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,ECWjB,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a340ee6..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 63d84c4d689ef6495b29e506b6a93068fd1a161d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 15:20:03 +0000 Subject: [PATCH 025/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 38 files changed, 2699 insertions(+), 4464 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3f46167..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T00:30:38.898Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 2ab64ca0c89415cfff7de9b51e7b72089985343d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 03:25:01 +0000 Subject: [PATCH 026/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index e8860dc..4875ff8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From ae80093500222d2c6ea9420cbd73a9bd5f219425 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 17:19:10 +0000 Subject: [PATCH 027/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 5be49a6..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js' ;\nimport isString from './is_string.js' ;\nimport formatDouble from './format_double.js' ;\nimport spacePad from './space_pad.js' ;\nimport zeroPad from './zero_pad.js' ;\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,ECCjB,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,EAeR,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,GAqCPM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,ECvCT,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,EAmCL,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,IA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uE,EAAO,GAChBjD,UAAaiD,EAAO,GACpBvD,UAAauD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCzD,EAAMQ,UAAY,KAEZR,EAgBR,SAAS0D,EAAgBzE,GACxB,IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,ECjDR,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,ECWjB,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cee8475..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 57d917582c4470ffabfe3620c9e9f41d2cb3d358 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 17:19:51 +0000 Subject: [PATCH 028/159] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 1092 --------- 38 files changed, 2699 insertions(+), 4464 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 168e7f8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T00:54:18.788Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From f9dce381745571e5ede29249a41232bddcc5b276 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 03:12:45 +0000 Subject: [PATCH 029/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index e8860dc..4875ff8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From ad17ee83af088da32940a7dad69d307e3450c21c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 10:38:46 +0000 Subject: [PATCH 030/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 2689 ---------------------------------------------------- 4 files changed, 2736 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 5be49a6..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js' ;\nimport isString from './is_string.js' ;\nimport formatDouble from './format_double.js' ;\nimport spacePad from './space_pad.js' ;\nimport zeroPad from './zero_pad.js' ;\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mapp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EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,ECjDR,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,ECWjB,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb8ee01..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 62db30cf0795419bd3c0f671e99b2731e58e4d3c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 10:39:21 +0000 Subject: [PATCH 031/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1092 ------ 38 files changed, 4054 insertions(+), 4464 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 68ea6ec..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T00:42:47.053Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 82b081cd39bdc9fe67748a0fceceb03bc8aa8e90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 20:52:00 +0000 Subject: [PATCH 032/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index e8860dc..4875ff8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From 57f4860894412accca4fb7641eb782be54b5aaf1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:25:43 +0000 Subject: [PATCH 033/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4044 ---------------------------------------------------- 4 files changed, 4091 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 5be49a6..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js' ;\nimport isString from './is_string.js' ;\nimport formatDouble from './format_double.js' ;\nimport spacePad from './space_pad.js' ;\nimport zeroPad from './zero_pad.js' ;\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,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IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 30c3bb5..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 68acaa9823a5250c479271650cf3e9b68d2c3f08 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:26:19 +0000 Subject: [PATCH 034/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1092 ------ 38 files changed, 4054 insertions(+), 4485 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 89b77e8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T20:42:03.954Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 605844163ff70f0ef4dff223633fa43fb96c60e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 00:42:47 +0000 Subject: [PATCH 035/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index 8965fea..aa68ccf 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From 47310cc06240a900aafaefd3b067749f9bd49025 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 07:39:20 +0000 Subject: [PATCH 036/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4044 ---------------------------------------------------- 4 files changed, 4091 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 5be49a6..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js' ;\nimport isString from './is_string.js' ;\nimport formatDouble from './format_double.js' ;\nimport spacePad from './space_pad.js' ;\nimport zeroPad from './zero_pad.js' ;\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate' ;\nimport tokenize from '@stdlib/string-base-format-tokenize' ;\nimport isString from './is_string.js' ;\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,IAAMA,IAEZA,EAAMD,EAAEyB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,EACzDjB,MAASiB,EAAO,GAChBvE,MAASuE,EAAO,GAChBjD,UAAaiD,EAAO,GACpBvD,UAAauD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCzD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAAS0D,EAAgBzE,GACxB,IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a62ad73..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From edfa738062e0905303668beaf4ba4b47f1e6a828 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 07:39:54 +0000 Subject: [PATCH 037/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1092 ------ 38 files changed, 4054 insertions(+), 4490 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 14dbf05..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T00:33:49.937Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From a7c4b150a48c124b24186d0a8a1c81cf111232c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 02:28:10 +0000 Subject: [PATCH 038/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index 56c60fd..8662bad 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From 972e81c70aa73065be8c57acbfbabda64cbbbcbe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 06:34:47 +0000 Subject: [PATCH 039/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4044 ---------------------------------------------------- 4 files changed, 4091 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 5be49a6..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,K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D1B,GAAOiB,EAAMG,KAAO,GACpB4C,GAAO,CACP,CAEF,OAAOhE,CACR,CC3LA,IAAIwE,EAAK,6EAYT,SAASC,EAAOC,GACf,IAAIzD,EAAQ,CACXyC,QAAagB,EAAO,GAAQrD,SAAUqD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBvE,MAASuE,EAAO,GAChBjD,UAAaiD,EAAO,GACpBvD,UAAauD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCzD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAAS0D,EAAgBzE,GACxB,IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 32f5e83..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 2381f2b004e9c7eea6b46b992e65c23d333c9692 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 06:35:38 +0000 Subject: [PATCH 040/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 1092 ------ 38 files changed, 4054 insertions(+), 4501 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index addb7fa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T00:31:53.210Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 348457ce6f0c1a048ac46de05d27e508bfaba6fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:16:30 +0000 Subject: [PATCH 041/159] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); diff --git a/package.json b/package.json index 56c60fd..8662bad 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/string-format", + "name": "@stdlib/error-tools-fmtprodmsg", "version": "0.0.3", "description": "Insert supplied variable values into a format string.", "license": "Apache-2.0", From ce49262a64830fbaf15c492d71547b19d67a0b33 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:51:11 +0000 Subject: [PATCH 042/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4044 ---------------------------------------------------- 4 files changed, 4091 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index e04d55d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UA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ACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 71e62f4..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 941bb8820b6157469d610dc22f0cf99da3a7c800 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:51:45 +0000 Subject: [PATCH 043/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 38 files changed, 6187 insertions(+), 4501 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index dc7039f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T00:34:19.561Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 243c792f54f8efd2c010b0f9bd284c4761f203f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 00:36:22 +0000 Subject: [PATCH 044/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 2c15638ac9113d1ce56c3e59ab6f50c61d029f14 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 00:50:52 +0000 Subject: [PATCH 045/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index e04d55d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAA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IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3b56f94..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1b94dd7a6f855745f9b86277e2e8468ebba0b0a0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 00:51:34 +0000 Subject: [PATCH 046/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 38 files changed, 6187 insertions(+), 4636 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b1996da..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T00:35:14.156Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 3a8b20934263d6ce702cc3b7dd79c29e18771e27 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 00:31:51 +0000 Subject: [PATCH 047/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From dc4a57fe4360102a5ef092ccf0578ef6eefaacdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 00:42:56 +0000 Subject: [PATCH 048/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index e04d55d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,IAAMA,IAEZA,EAAMD,EAAEyB,SAAUN,GACZnB,GAAMkB,EAAMQ,UAENR,EAAMQ,YACjBzB,EAAMC,EAASD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GACpBvD,UAAauD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCzD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAAS0D,EAAgBzE,GACxB,IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 04e9a10..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a8c0197e2aa0c41b751f57bf544a483abfddd0bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 00:43:39 +0000 Subject: [PATCH 049/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 38 files changed, 6187 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 223073d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T00:31:04.905Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 4bb39541c0a0644a041b979582d7304ca88e536b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 00:31:54 +0000 Subject: [PATCH 050/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 532fa5092ead68da6ba033bddf86ef7da3030927 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 00:45:48 +0000 Subject: [PATCH 051/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index e04d55d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MA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ats.html deleted file mode 100644 index 4ebd829..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0f2d4d4e0d4a1f0f9facfed9a6790cf6a7efe950 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 00:46:52 +0000 Subject: [PATCH 052/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 38 files changed, 6187 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b0aa3a6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T00:30:50.758Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 6b03d698e9beac4f86c0510aff7c2c88a52f7cae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 00:41:39 +0000 Subject: [PATCH 053/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From dc27c3fa8a927a0264a935e086ff628091329342 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 00:56:45 +0000 Subject: [PATCH 054/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index e04d55d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,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VA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 71e9dfd..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 806d862b4356d9d161b9ce36d4b0c511e1415620 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 00:57:20 +0000 Subject: [PATCH 055/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 38 files changed, 6187 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index de1d018..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T00:40:42.878Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From c859729d37731c8b8de339ae3b4c750ceb26df6e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 00:39:29 +0000 Subject: [PATCH 056/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 82753fd50f1a73d09471c2b8d9e46c53fb2779d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 00:52:27 +0000 Subject: [PATCH 057/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index e04d55d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,E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AS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c97d6b0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b9f90752e13e7981bd1a9da26930162a0ced2764 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 00:53:16 +0000 Subject: [PATCH 058/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 38 files changed, 6187 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 25f42c8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T00:38:34.160Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From fa0dd0639548f218e68a62d08c6f6d7cd9387924 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 00:35:47 +0000 Subject: [PATCH 059/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..abe26f3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '0hB3R', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 5d08fdd84e1eb5a9423cff4de7704cfb53f095c6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 00:53:48 +0000 Subject: [PATCH 060/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index e04d55d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GACl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AAIwE,EAAK,6EAYT,SAASC,EAAOC,GACf,IAAIzD,EAAQ,CACXyC,QAAagB,EAAO,GAAQrD,SAAUqD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBvE,MAASuE,EAAO,GAChBjD,UAAaiD,EAAO,GACpBvD,UAAauD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCzD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAAS0D,EAAgBzE,GACxB,IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,QAAShF,IAKvC,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fc69dfb..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4de72784a33c65a4ed24342ee17ac57bc3b20a68 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 00:54:27 +0000 Subject: [PATCH 061/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 38 files changed, 6187 insertions(+), 4642 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e72ccf4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T00:34:41.271Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 334eb59..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 8f470b22e970fbffbd7725caf5ebafc9b926ba2d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 00:39:36 +0000 Subject: [PATCH 062/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..630a353 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F,Ex', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 8f899d9d7bc03036bfcfe2e4b22b538ad0c4e467 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 00:50:54 +0000 Subject: [PATCH 063/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 7ae7765..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index e04d55d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var I=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function V(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=I.exec(e);a;)(r=e.slice(t,I.lastIndex-a[0].length)).length&&i.push(r),i.push(V(a)),t=I.lastIndex,a=I.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function R(e){return"string"==typeof e}function A(e){var r,i,a;if(!R(e))throw new TypeError(A("0hB3R",e));for(r=F(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '0hB3R', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAE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iF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8262fe3..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1186f13c43e3de0e25a0dcb63ada374da54ad2e8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 00:51:39 +0000 Subject: [PATCH 064/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 40 files changed, 6187 insertions(+), 4643 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From afcd1ad20f3375544f831d637eeec20c13e38e2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 03:03:39 +0000 Subject: [PATCH 065/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..630a353 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F,Ex', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 3bc9ecf2681adfbc0cea5ac90b41e7e40c59520b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 03:16:05 +0000 Subject: [PATCH 066/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 32662fa..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var F=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function I(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function V(e){var r,i,a,t;for(i=[],t=0,a=F.exec(e);a;)(r=e.slice(t,F.lastIndex-a[0].length)).length&&i.push(r),i.push(I(a)),t=F.lastIndex,a=F.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function A(e){return"string"==typeof e}function C(e){var r,i,a;if(!A(e))throw new TypeError(C("1Of3F,Ex",e));for(r=V(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F,Ex', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB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MpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 254a26d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2b909fc1c75d542ea8364de7b9fef77cc4fb14d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 03:16:49 +0000 Subject: [PATCH 067/159] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 1092 ---- 41 files changed, 6187 insertions(+), 4678 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 848916a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ca63e2d..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From b1257b7b3399efcc4241680afd224334377f6c2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 03:23:55 +0000 Subject: [PATCH 068/159] Update README.md for Deno bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c1d172..f524eef 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ limitations under the License. ## Usage ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.0-deno/mod.js'; ``` #### format( str, ...args ) @@ -226,7 +226,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.0-deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From 9c06b9f98942a783b5c7ca686017f3b411d8637d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 03:23:56 +0000 Subject: [PATCH 069/159] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f524eef..a98884d 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +``` +The previous example will load the latest bundled code from the deno branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/string-format/tags). For example, + ```javascript import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.0-deno/mod.js'; ``` @@ -226,7 +231,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.0-deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From 60195afa0ec99f532f3b0ade8debd640d8a5ce2f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 00:35:01 +0000 Subject: [PATCH 070/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..630a353 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F,Ex', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 1448c1adac9d0929ac3160e904204e1df21eefca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 01:26:19 +0000 Subject: [PATCH 071/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 32662fa..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var F=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function I(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function V(e){var r,i,a,t;for(i=[],t=0,a=F.exec(e);a;)(r=e.slice(t,F.lastIndex-a[0].length)).length&&i.push(r),i.push(I(a)),t=F.lastIndex,a=F.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function A(e){return"string"==typeof e}function C(e){var r,i,a;if(!A(e))throw new TypeError(C("1Of3F,Ex",e));for(r=V(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F,Ex', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMi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R,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1757564..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 984ea2b68e216ba8c3a49baa76e2c5e9c4673c96 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 01:27:05 +0000 Subject: [PATCH 072/159] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1092 ---- test/test.js | 1092 ---- 43 files changed, 6187 insertions(+), 5829 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0880282..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T00:32:24.337Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index aa1197c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index c6289c2..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 67d42623a6084e32593139e5503b6e8902f9eda6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 22:48:51 +0000 Subject: [PATCH 073/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..630a353 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F,Ex', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 934897796bfa1cff1efcc129473a360f0be91e09 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 00:10:49 +0000 Subject: [PATCH 074/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 32662fa..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var F=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function I(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function V(e){var r,i,a,t;for(i=[],t=0,a=F.exec(e);a;)(r=e.slice(t,F.lastIndex-a[0].length)).length&&i.push(r),i.push(I(a)),t=F.lastIndex,a=F.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function A(e){return"string"==typeof e}function C(e){var r,i,a;if(!A(e))throw new TypeError(C("1Of3F,Ex",e));for(r=V(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F,Ex', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,I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AAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e72fa13..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 757cd2d7a1a8dbd3dd56b8a3dbc18d9c6677d86b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 00:11:26 +0000 Subject: [PATCH 075/159] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1092 ---- test/test.js | 1092 ---- 42 files changed, 6187 insertions(+), 5828 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index aa1197c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index c6289c2..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From fa680f04d922f291d4a4f0deb36c06459320cc34 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 02:25:20 +0000 Subject: [PATCH 076/159] Update README.md for Deno bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a81a70..8cfe6a7 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ limitations under the License. ## Usage ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-deno/mod.js'; ``` #### format( str, ...args ) @@ -226,7 +226,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From fb53ae4d661b445304cb6024413e13e63390cc97 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 02:25:21 +0000 Subject: [PATCH 077/159] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cfe6a7..2c0c43c 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +``` +The previous example will load the latest bundled code from the deno branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/string-format/tags). For example, + ```javascript import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-deno/mod.js'; ``` @@ -226,7 +231,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From a1b7fd1a101988d2a16a5c5cd70ddd27a4df4cfe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 02:34:45 +0000 Subject: [PATCH 078/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..630a353 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F,Ex', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From 2153a14f008cff71792c5fda6b8c4e5d7f98302c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 02:45:41 +0000 Subject: [PATCH 079/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 32662fa..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var F=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function I(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function V(e){var r,i,a,t;for(i=[],t=0,a=F.exec(e);a;)(r=e.slice(t,F.lastIndex-a[0].length)).length&&i.push(r),i.push(I(a)),t=F.lastIndex,a=F.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function A(e){return"string"==typeof e}function C(e){var r,i,a;if(!A(e))throw new TypeError(C("1Of3F,Ex",e));for(r=V(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F,Ex', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL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AU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 12419bb..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f2ace0bff64f94b83fffce8f27653a23a41d8934 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 02:46:29 +0000 Subject: [PATCH 080/159] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 1092 ---- test/test.js | 1092 ---- 42 files changed, 6187 insertions(+), 5828 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index aa1197c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index c6289c2..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From c17a9d189a783b7a32b8d6f9fefce66bd25a892c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 00:32:43 +0000 Subject: [PATCH 081/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index c08c83c..630a353 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F,Ex', str ) ); } tokens = tokenize( str ); args = new Array( arguments.length ); From b1bcd236577316b1bbd55de57425f58c9a1f740d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 01:25:39 +0000 Subject: [PATCH 082/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 32662fa..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var F=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function I(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function V(e){var r,i,a,t;for(i=[],t=0,a=F.exec(e);a;)(r=e.slice(t,F.lastIndex-a[0].length)).length&&i.push(r),i.push(I(a)),t=F.lastIndex,a=F.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function A(e){return"string"==typeof e}function C(e){var r,i,a;if(!A(e))throw new TypeError(C("1Of3F,Ex",e));for(r=V(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F,Ex', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB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MpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 10ce787..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 172efbc2ad94e137b4353c048696a22e3f655baf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 01:26:13 +0000 Subject: [PATCH 083/159] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 67 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 43 files changed, 6187 insertions(+), 4778 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 22566ce..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T00:30:35.082Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index aa1197c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 1ce5ff1468168ef7a5621071a9532f5bf1617d1c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 7 Nov 2023 05:48:04 +0000 Subject: [PATCH 084/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..d38ae26 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F,Ex', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 0631cad0e83adfc767ef0e2cd55ef8922a0037bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 7 Nov 2023 05:48:34 +0000 Subject: [PATCH 085/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 32662fa..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):x(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=y(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var F=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function I(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function V(e){var r,i,a,t;for(i=[],t=0,a=F.exec(e);a;)(r=e.slice(t,F.lastIndex-a[0].length)).length&&i.push(r),i.push(I(a)),t=F.lastIndex,a=F.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function A(e){return"string"==typeof e}function C(e){var r,i,a;if(!A(e))throw new TypeError(C("1Of3F,Ex",e));for(r=V(e),(i=new Array(arguments.length))[0]=r,a=1;a 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar tokens;\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F,Ex', str ) );\n\t}\n\ttokens = tokenize( str );\n\targs = new Array( arguments.length );\n\targs[ 0 ] = tokens;\n\tfor ( i = 1; i < args.length; i++ ) {\n\t\targs[ i ] = arguments[ i ];\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GA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AAMQ,UAAY,KAEZR,CACR,CAeA,SAAS0D,EAAgBzE,GACxB,IAAI0E,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM5E,GACTwE,IACPE,EAAU1E,EAAI6E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAI0D,EACAuB,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,WAAYhF,IAK1C,IAHA0D,EAASwB,EAAUlF,IACnBiF,EAAO,IAAI5B,MAAOc,UAAU9D,SACtB,GAAMqD,EACN7D,EAAI,EAAGA,EAAIoF,EAAK5E,OAAQR,IAC7BoF,EAAMpF,GAAMsE,UAAWtE,GAExB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5cb37e2..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a1fac8430ae166a9f6777324e103d8e08c2a4a1a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 7 Nov 2023 05:49:18 +0000 Subject: [PATCH 086/159] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 42 files changed, 6187 insertions(+), 4774 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index aa1197c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 6b2c38eb99063440290846421fea907ade65f9cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 00:35:16 +0000 Subject: [PATCH 087/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..d38ae26 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F,Ex', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 638a1ea9a07d34085418133856fc5158c645bd04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 01:09:07 +0000 Subject: [PATCH 088/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index a341280..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):y(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=x(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var F=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function I(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function V(e){var r,i,a,t;for(i=[],t=0,a=F.exec(e);a;)(r=e.slice(t,F.lastIndex-a[0].length)).length&&i.push(r),i.push(I(a)),t=F.lastIndex,a=F.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function C(e){return"string"==typeof e}function R(e){var r,i;if(!C(e))throw new TypeError(R("1Of3F,Ex",e));for(r=[V(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F,Ex', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB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diff --git a/stats.html b/stats.html deleted file mode 100644 index 72023d7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 22a44fe2b6f7e5a9862eb7066a928b8f0dcf1923 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 01:09:38 +0000 Subject: [PATCH 089/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 22 +- benchmark/benchmark.js | 73 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 43 files changed, 6187 insertions(+), 4770 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3ab2f32..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T00:32:53.441Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index aa1197c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 8da48ca4659b517ea647a8d8c8e99b4813c4c295 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 15:16:44 +0000 Subject: [PATCH 090/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 51bb5b349cead17547fa814a3dce89a8d9018ba2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 15:23:51 +0000 Subject: [PATCH 091/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 6177 ---------------------------------------------------- 4 files changed, 6224 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index a341280..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=l.call(a,v,"$1e"),a=l.call(a,w,"e"),a=l.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=l.call(a,g,"e+0$1"),a=l.call(a,f,"e-0$1"),r.alternate&&(a=l.call(a,u,"$1."),a=l.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===p.call(r.specifier)?p.call(a):c.call(a)}function m(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=k(c)?String(t.arg):y(c)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=b(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=x(t.arg,t.width,t.padRight)),p+=t.arg||"",l+=1}return p}var F=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function I(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function V(e){var r,i,a,t;for(i=[],t=0,a=F.exec(e);a;)(r=e.slice(t,F.lastIndex-a[0].length)).length&&i.push(r),i.push(I(a)),t=F.lastIndex,a=F.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function C(e){return"string"==typeof e}function R(e){var r,i;if(!C(e))throw new TypeError(R("1Of3F,Ex",e));for(r=[V(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F,Ex', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","isString","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","spacePad","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC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Q,UAAYN,EAAO,GAAInE,SACxCA,QACZqD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM5E,GAMlB,OAJA0E,EAAU1E,EAAI6E,MAAOF,IACRtE,QACZqD,EAAOqB,KAAML,GAEPhB,CACR,CClDA,SAAS7B,EAAUnC,GAClB,MAA0B,iBAAVA,CACjB,CCUA,SAASsF,EAAQhF,GAChB,IAAIiF,EACApF,EAEJ,IAAMgC,EAAU7B,GACf,MAAM,IAAIgE,UAAWgB,EAAQ,WAAYhF,IAG1C,IADAiF,EAAO,CAAEC,EAAUlF,IACbH,EAAI,EAAGA,EAAIsE,UAAU9D,OAAQR,IAClCoF,EAAKF,KAAMZ,UAAWtE,IAEvB,OAAOsF,EAAYC,MAAO,KAAMH,EACjC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 307cc16..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b4230c15956052ab003967068708556faf1abc9b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 15:24:05 +0000 Subject: [PATCH 092/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 43 files changed, 4852 insertions(+), 4778 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From dfdd6c6f6dd645611714289c672e24945b442367 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 15:24:53 +0000 Subject: [PATCH 093/159] Update README.md for Deno bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ddd8dc8..9536ba2 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ limitations under the License. ## Usage ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.2.1-deno/mod.js'; ``` #### format( str, ...args ) @@ -226,7 +226,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.2.1-deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From b83cf0d15de7e997d15bd26fa81aed2b96217cb5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 15:24:53 +0000 Subject: [PATCH 094/159] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9536ba2..8bb83df 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +``` +The previous example will load the latest bundled code from the deno branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/string-format/tags). For example, + ```javascript import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.2.1-deno/mod.js'; ``` @@ -226,7 +231,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.2.1-deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From dc3a24f6c473ef604f8d04c4628b26aa6bb9a0d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 00:33:52 +0000 Subject: [PATCH 095/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 900f07a91f6046f55ba26948f0aa4b15ba31c942 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 00:39:51 +0000 Subject: [PATCH 096/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index b44981b..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=y(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var $=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function S(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=$.exec(e);a;)(r=e.slice(t,$.lastIndex-a[0].length)).length&&i.push(r),i.push(S(a)),t=$.lastIndex,a=$.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJ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+E,EACAlF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI8D,UAAWgB,EAAQ,QAAS9E,IAGvC,IADA+E,EAAO,CAAEC,EAAUhF,IACbH,EAAI,EAAGA,EAAIoE,UAAU5D,OAAQR,IAClCkF,EAAKF,KAAMZ,UAAWpE,IAEvB,OAAOoF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 38482c7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 62fdc3e1581ebd251e220fe78229806832a8b647 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 00:40:19 +0000 Subject: [PATCH 097/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4780 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1d36147..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T00:32:34.744Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 2a13adf4cdb0253ebe9e2a521338dc6945188140 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 00:33:35 +0000 Subject: [PATCH 098/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 7f3e4740b4f3021c7cea1845b53c9e4f64addac9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 00:44:28 +0000 Subject: [PATCH 099/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index b44981b..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=y(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var $=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function S(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=$.exec(e);a;)(r=e.slice(t,$.lastIndex-a[0].length)).length&&i.push(r),i.push(S(a)),t=$.lastIndex,a=$.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf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AAKF,KAAMZ,UAAWpE,IAEvB,OAAOoF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 38482c7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fd7e790fa3d09ddea143d1e3221a066a87bc7050 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 00:44:42 +0000 Subject: [PATCH 100/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4783 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1266f51..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T00:32:35.058Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From f2dd7308a8be73f5a6d065ed6793d0c1afa39a1f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 20:43:10 +0000 Subject: [PATCH 101/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 856e5752000ae71ea631d83738c285300be8f339 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 20:53:06 +0000 Subject: [PATCH 102/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index b44981b..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=y(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var $=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function S(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=$.exec(e);a;)(r=e.slice(t,$.lastIndex-a[0].length)).length&&i.push(r),i.push(S(a)),t=$.lastIndex,a=$.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,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S,SDvJnDpB,YAAMH,EAAQD,EAAIK,QACX,EACHL,EAERA,EAAM,EACLA,EAAM8C,EAAQ1C,GACd0C,EAAQ1C,GAAQJ,ICmJfF,GAAOiB,EAAMG,KAAO,GACpB0C,GAAO,CACP,CAEF,OAAO9D,CACR,CE3LA,IAAIsE,EAAK,6EAYT,SAASC,EAAOC,GACf,IAAIvD,EAAQ,CACXuC,QAAagB,EAAO,GAAQnD,SAAUmD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBrE,MAASqE,EAAO,GAChB/C,UAAa+C,EAAO,GACpBrD,UAAaqD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCvD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASwD,EAAgBvE,GACxB,IAAIwE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM1E,GACTsE,IACPE,EAAUxE,EAAI2E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIjE,SACxCA,QACZmD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM1E,GAMlB,OAJAwE,EAAUxE,EAAI2E,MAAOF,IACRpE,QACZmD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ9E,GAChB,IAAI+E,EACAlF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI8D,UAAWgB,EAAQ,QAAS9E,IAGvC,IADA+E,EAAO,CAAEC,EAAUhF,IACbH,EAAI,EAAGA,EAAIoE,UAAU5D,OAAQR,IAClCkF,EAAKF,KAAMZ,UAAWpE,IAEvB,OAAOoF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 38482c7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1e3e03f22c336570da3265004980a8e9c58fd742 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 20:53:18 +0000 Subject: [PATCH 103/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 43 files changed, 4852 insertions(+), 4784 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From afaf2254d4390157a84c5196e8c9cd99b8d88044 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 00:32:59 +0000 Subject: [PATCH 104/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 54408d77670b28065062914f08eb639be6921f8d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 00:45:30 +0000 Subject: [PATCH 105/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index b44981b..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=y(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var $=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function S(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=$.exec(e);a;)(r=e.slice(t,$.lastIndex-a[0].length)).length&&i.push(r),i.push(S(a)),t=$.lastIndex,a=$.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,IAAMA,IAEZA,EAAMD,EAAEyB,SAAUN,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B/C,UAAa+C,EAAO,GACpBrD,UAAaqD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCvD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASwD,EAAgBvE,GACxB,IAAIwE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM1E,GACTsE,IACPE,EAAUxE,EAAI2E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIjE,SACxCA,QACZmD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM1E,GAMlB,OAJAwE,EAAUxE,EAAI2E,MAAOF,IACRpE,QACZmD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ9E,GAChB,IAAI+E,EACAlF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI8D,UAAWgB,EAAQ,QAAS9E,IAGvC,IADA+E,EAAO,CAAEC,EAAUhF,IACbH,EAAI,EAAGA,EAAIoE,UAAU5D,OAAQR,IAClCkF,EAAKF,KAAMZ,UAAWpE,IAEvB,OAAOoF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 38482c7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c9d0f8e4c47ca4751390983da8d9b2f5d5056fb6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 00:45:50 +0000 Subject: [PATCH 106/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4792 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fdee2f7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-05-01T00:31:47.819Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 71e651eee9d3ac2a4a52820856301f647bf49c25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 00:35:10 +0000 Subject: [PATCH 107/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 305e5e4af37915132236934714ef4d8a424b3fa2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 00:46:39 +0000 Subject: [PATCH 108/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index b44981b..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=y(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var $=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function S(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=$.exec(e);a;)(r=e.slice(t,$.lastIndex-a[0].length)).length&&i.push(r),i.push(S(a)),t=$.lastIndex,a=$.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,IAAMA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EAAO,GAChBrE,MAASqE,EAAO,GAChB/C,UAAa+C,EAAO,GACpBrD,UAAaqD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCvD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASwD,EAAgBvE,GACxB,IAAIwE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM1E,GACTsE,IACPE,EAAUxE,EAAI2E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIjE,SACxCA,QACZmD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM1E,GAMlB,OAJAwE,EAAUxE,EAAI2E,MAAOF,IACRpE,QACZmD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ9E,GAChB,IAAI+E,EACAlF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI8D,UAAWgB,EAAQ,QAAS9E,IAGvC,IADA+E,EAAO,CAAEC,EAAUhF,IACbH,EAAI,EAAGA,EAAIoE,UAAU5D,OAAQR,IAClCkF,EAAKF,KAAMZ,UAAWpE,IAEvB,OAAOoF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 38482c7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8931d6ffc4d980ebe7a6d958171d905ed01dc90e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 00:46:51 +0000 Subject: [PATCH 109/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4792 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 85c3be7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-06-01T00:33:58.200Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 572a4a5f23e08580c2a3d72754f558279fec6418 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 00:38:46 +0000 Subject: [PATCH 110/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 245b6c9d1272d5f5835571f9a981d837107d7cbe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 00:48:21 +0000 Subject: [PATCH 111/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index b44981b..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=y(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var $=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function S(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=$.exec(e);a;)(r=e.slice(t,$.lastIndex-a[0].length)).length&&i.push(r),i.push(S(a)),t=$.lastIndex,a=$.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAW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AO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBrE,MAASqE,EAAO,GAChB/C,UAAa+C,EAAO,GACpBrD,UAAaqD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCvD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASwD,EAAgBvE,GACxB,IAAIwE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM1E,GACTsE,IACPE,EAAUxE,EAAI2E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIjE,SACxCA,QACZmD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM1E,GAMlB,OAJAwE,EAAUxE,EAAI2E,MAAOF,IACRpE,QACZmD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ9E,GAChB,IAAI+E,EACAlF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI8D,UAAWgB,EAAQ,QAAS9E,IAGvC,IADA+E,EAAO,CAAEC,EAAUhF,IACbH,EAAI,EAAGA,EAAIoE,UAAU5D,OAAQR,IAClCkF,EAAKF,KAAMZ,UAAWpE,IAEvB,OAAOoF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 38482c7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 283dd8d36a814e6f09bdc9a3865853f4ee0ce43c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 00:48:42 +0000 Subject: [PATCH 112/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 38 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4829 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ef5c4c8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T00:37:20.621Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From e306ffb70758273eb86fb77bf3ed57c1f70ad474 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:17:08 +0000 Subject: [PATCH 113/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 7d87a7ee41549e70e5f37298971615385298fbd5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:18:00 +0000 Subject: [PATCH 114/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index b44981b..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=y(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var $=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function S(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=$.exec(e);a;)(r=e.slice(t,$.lastIndex-a[0].length)).length&&i.push(r),i.push(S(a)),t=$.lastIndex,a=$.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e');\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isnan = isNaN; // NOTE: We use the global `isNaN` function here instead of `@stdlib/math/base/assert/is-nan` to avoid circular dependencies.\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ?\n\t\t\t\t\t\tString( token.arg ) :\n\t\t\t\t\t\tfromCharCode( num );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isnan","isNaN","isArray","Array","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,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C,QAAagB,EAAO,GAAQnD,SAAUmD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBrE,MAASqE,EAAO,GAChB/C,UAAa+C,EAAO,GACpBrD,UAAaqD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCvD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASwD,EAAgBvE,GACxB,IAAIwE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAM1E,GACTsE,IACPE,EAAUxE,EAAI2E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIjE,SACxCA,QACZmD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAM1E,GAMlB,OAJAwE,EAAUxE,EAAI2E,MAAOF,IACRpE,QACZmD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ9E,GAChB,IAAI+E,EACAlF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI8D,UAAWgB,EAAQ,QAAS9E,IAGvC,IADA+E,EAAO,CAAEC,EAAUhF,IACbH,EAAI,EAAGA,EAAIoE,UAAU5D,OAAQR,IAClCkF,EAAKF,KAAMZ,UAAWpE,IAEvB,OAAOoF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 38482c7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d28287a51b48651f88eeb5d1338f8cd1bf266acd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:18:13 +0000 Subject: [PATCH 115/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 152 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 43 files changed, 4852 insertions(+), 4942 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 4196429c8dbfed746420c581e34eceddabc61e82 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:18:26 +0000 Subject: [PATCH 116/159] Update README.md for Deno bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 613e382..2013471 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ limitations under the License. ## Usage ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.2.2-deno/mod.js'; ``` #### format( str, ...args ) @@ -226,7 +226,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.2.2-deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From 0c03612e2b5497db0623e503ee4e8ea2c16fd79b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:18:26 +0000 Subject: [PATCH 117/159] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2013471..3b1e3c2 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; +``` +The previous example will load the latest bundled code from the deno branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/string-format/tags). For example, + ```javascript import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.2.2-deno/mod.js'; ``` @@ -226,7 +231,7 @@ out = format( str, 7 ); ```javascript -import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.2.2-deno/mod.js'; +import format from 'https://cdn.jsdelivr.net/gh/stdlib-js/string-format@deno/mod.js'; var out = format( '%s %s!', 'Hello', 'World' ); // returns 'Hello World!' From 4afc9409281e96d531571ec7cd22009d6c68e66c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 00:38:40 +0000 Subject: [PATCH 118/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 6e024317f4dccafa511f808ce1a3a4191a1f93e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 00:47:36 +0000 Subject: [PATCH 119/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MA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,EACLA,EAAM8C,EAAQ1C,GACd0C,EAAQ1C,GAAQJ,ICoKfF,GAAOiB,EAAMG,KAAO,GACpByC,GAAO,CACP,CAEF,OAAO7D,CACR,CE5MA,IAAIqE,EAAK,6EAYT,SAASC,EAAOC,GACf,IAAItD,EAAQ,CACXsC,QAAagB,EAAO,GAAQlD,SAAUkD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBpE,MAASoE,EAAO,GAChB9C,UAAa8C,EAAO,GACpBpD,UAAaoD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZkD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3c07767e174ad7e71b98e5bbaca72eacaaaf31a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 00:47:48 +0000 Subject: [PATCH 120/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4911 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8ccb312..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T00:37:23.248Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From bee0a54c328124452dd4730c3563ba6d2ec285eb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:14:56 +0000 Subject: [PATCH 121/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 085cfb8956884eb069c876fd1592c51c8e23fe2a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:20:53 +0000 Subject: [PATCH 122/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAE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,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2c1de6c5072b9649104ff48ffc6727807efce07f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:21:05 +0000 Subject: [PATCH 123/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 152 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4945 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 41560e2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T15:13:50.261Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From b450fece65e3fc77ad449a398e9672b509819175 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 00:44:40 +0000 Subject: [PATCH 124/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From aa98eec81e0a77a4936ace77f7ee29914af85c71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 00:53:53 +0000 Subject: [PATCH 125/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KAC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IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7e4f4d1acd1a25180b515ed6553e150598dd54ad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 00:54:13 +0000 Subject: [PATCH 126/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 152 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4945 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1600ab8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T00:43:34.486Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From f4bdb78a87d4504630ff2b0500b173a90a7de1a0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:30:11 +0000 Subject: [PATCH 127/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From cb4fb42b0f70b9300ce828d90f2431ea90508a23 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:43:32 +0000 Subject: [PATCH 128/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index 643f790..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param ...args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iB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AO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZkD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7e247848e5f8cde4c50eb5e5f1977946c6d260b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:43:48 +0000 Subject: [PATCH 129/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 186 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 43 files changed, 4852 insertions(+), 4978 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From a5ff8f26f5da7cb6c1c4618b8787a322e5265d38 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 00:44:33 +0000 Subject: [PATCH 130/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 4e44619364968e9260a39a50ef9ddf82f88e6ad5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 00:52:16 +0000 Subject: [PATCH 131/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,IAAMA,IAEZA,EAAMD,EAAEyB,SAAUN,GACZnB,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AAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBpE,MAASoE,EAAO,GAChB9C,UAAa8C,EAAO,GACpBpD,UAAaoD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZkD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0250c361d534610a87b8f42c1cfda7dd18579921 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 00:52:29 +0000 Subject: [PATCH 132/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 186 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4979 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fdb2200..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T00:43:27.762Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 95aa74b3a6351980312d811e9423c6cab1bfb168 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 00:45:08 +0000 Subject: [PATCH 133/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 0577ec2165964f19d1ef3bb11767bfd6eec11fee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 00:51:09 +0000 Subject: [PATCH 134/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2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EAAMS,SDxKnDpB,YAAMH,EAAQD,EAAIK,QACX,EACHL,EAERA,EAAM,EACLA,EAAM8C,EAAQ1C,GACd0C,EAAQ1C,GAAQJ,ICoKfF,GAAOiB,EAAMG,KAAO,GACpByC,GAAO,CACP,CAEF,OAAO7D,CACR,CE5MA,IAAIqE,EAAK,6EAYT,SAASC,EAAOC,GACf,IAAItD,EAAQ,CACXsC,QAAagB,EAAO,GAAQlD,SAAUkD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBpE,MAASoE,EAAO,GAChB9C,UAAa8C,EAAO,GACpBpD,UAAaoD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZkD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 43165481925913d53cf4eaf5c8c976621d7d1946 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 00:51:22 +0000 Subject: [PATCH 135/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 186 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ----- 44 files changed, 4852 insertions(+), 4979 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 089f484..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T00:43:56.361Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 418c23d1053886c79f05ee5b48b6ca0c5d17ae45 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 00:51:34 +0000 Subject: [PATCH 136/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 9ab9c6ea39ddb78926a08fe085c0c68fc01c1834 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 00:59:19 +0000 Subject: [PATCH 137/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,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D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9cc0ed71ec4b4434578c3949f21609463b8d998f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 00:59:38 +0000 Subject: [PATCH 138/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 186 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 45 files changed, 4852 insertions(+), 5084 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 502d45e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T00:50:27.199Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From f527126e1d88118b810ec413c42fb5f58596d404 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Dec 2024 01:18:35 +0000 Subject: [PATCH 139/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 77656d10f973c7e72643555675d3282421f6078f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Dec 2024 01:25:52 +0000 Subject: [PATCH 140/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EA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AO,SAA8B,IAAfA,EAAO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZkD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e059bfde3636cc1fab8d56d7be6bc16ee4d8f92f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Dec 2024 01:26:08 +0000 Subject: [PATCH 141/159] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 187 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 44 files changed, 4852 insertions(+), 5084 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 95150e0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 6976fd1c3ff3b84fcfd76ffffbb1cdafc4c3b79a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:02:45 +0000 Subject: [PATCH 142/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 029f102da4c7247349cb97df9f52aab38d49e46d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:56:29 +0000 Subject: [PATCH 143/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 59d7a13..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR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AOC,GACf,IAAItD,EAAQ,CACXsC,QAAagB,EAAO,GAAQlD,SAAUkD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBpE,MAASoE,EAAO,GAChB9C,UAAa8C,EAAO,GACpBpD,UAAaoD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZkD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9d74b9d8b239cb517ea1852eeb7e32ce14e19791 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:56:45 +0000 Subject: [PATCH 144/159] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 187 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 45 files changed, 4852 insertions(+), 5088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5c2657b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T01:44:51.482Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 758f430..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From fbdc5129850d5adb506ab5cc4c1c3c063f95fa21 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Mar 2025 00:28:58 +0000 Subject: [PATCH 145/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 2eb06f9e70f9f8cfeaf5df09926ff68acc7d7457 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Mar 2025 00:34:07 +0000 Subject: [PATCH 146/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 25ab23d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EA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,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e1ac54982fa508347f5e7a32d6682ff823ddc15b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Mar 2025 00:34:35 +0000 Subject: [PATCH 147/159] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 187 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 45 files changed, 4852 insertions(+), 5088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fd63b2c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-03T00:28:24.243Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 758f430..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 6ada682b13d873b6ebd26c17c9b0d7466f3ab7d6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:31:36 +0000 Subject: [PATCH 148/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 3e9cc3fa980d9223f07ecbf1448109e846c5455c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:04:39 +0000 Subject: [PATCH 149/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 25ab23d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAI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EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZkD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 43ff72eb581fc021ade9f95799148ded78fd42e4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:04:50 +0000 Subject: [PATCH 150/159] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 187 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 45 files changed, 4852 insertions(+), 5088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e603b51..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T01:20:38.202Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 758f430..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 686ba0d563b531c4a7fb93a2108447bd8ea31c61 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:08:16 +0000 Subject: [PATCH 151/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 6deabee643d48eccd75d7557b8f75708303020b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:30:58 +0000 Subject: [PATCH 152/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 25ab23d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,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CACXsC,QAAagB,EAAO,GAAQlD,SAAUkD,EAAO,GAAK,SAAO,EACzDjB,MAASiB,EAAO,GAChBpE,MAASoE,EAAO,GAChB9C,UAAa8C,EAAO,GACpBpD,UAAaoD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAhB,EACAc,EACAG,EAKJ,IAHAjB,EAAS,GACTiB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZkD,EAAOqB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ff9ba7e603df3f55b97632e90847117f5d14c488 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:31:14 +0000 Subject: [PATCH 153/159] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 187 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 45 files changed, 4852 insertions(+), 5088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6a79105..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-19T01:05:06.598Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 758f430..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From ac0b3fb89d32081c0e6823753f7f02c47f3d1667 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 02:06:45 +0000 Subject: [PATCH 154/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 767aac14b42a7e0f4663bb0b44e0efc5db578774 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 03:02:39 +0000 Subject: [PATCH 155/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 25ab23d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,E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E,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2de053940e6477096a62293481bed51a08ff8bc3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 03:03:13 +0000 Subject: [PATCH 156/159] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 187 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 45 files changed, 4852 insertions(+), 5088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 78a1730..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-30T01:44:47.924Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 758f430..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); From 55dd1fb2c1fd08624ef4fddf46f0696d089856a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 21 Jul 2025 01:02:05 +0000 Subject: [PATCH 157/159] Transform error messages --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 40d7310..a221e52 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,7 +49,7 @@ function format( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); + throw new TypeError( format( '1Of3F', str ) ); } args = [ tokenize( str ) ]; for ( i = 1; i < arguments.length; i++ ) { From 2942f839cb88df2815fe3165965d183c49bf08df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 21 Jul 2025 01:04:59 +0000 Subject: [PATCH 158/159] Remove files --- mod.d.ts | 42 - mod.js | 4 - mod.js.map | 1 - stats.html | 4842 ---------------------------------------------------- 4 files changed, 4889 deletions(-) delete mode 100644 mod.d.ts delete mode 100644 mod.js delete mode 100644 mod.js.map delete mode 100644 stats.html diff --git a/mod.d.ts b/mod.d.ts deleted file mode 100644 index cecb88d..0000000 --- a/mod.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Inserts supplied variable values into a format string. -* -* @param str - input string -* @param args - variable values -* @throws invalid flags -* @returns formatted string -* -* @example -* var str = format( 'Hello %s!', 'world' ); -* // returns 'Hello world!' -* -* @example -* var str = format( 'Pi: ~%.2f', 3.141592653589793 ); -* // returns 'Pi: ~3.14' -*/ -declare function format( str: string, ...args: Array ): string; - - -// EXPORTS // - -export = format; diff --git a/mod.js b/mod.js deleted file mode 100644 index 25ab23d..0000000 --- a/mod.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -function e(e){return"number"==typeof e}function r(e){var r,i="";for(r=0;r0&&(i-=1),a=t.toExponential(i)):a=t.toPrecision(r.precision),r.alternate||(a=p.call(a,w,"$1e"),a=p.call(a,u,"e"),a=p.call(a,h,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return a=p.call(a,l,"e+0$1"),a=p.call(a,g,"e-0$1"),r.alternate&&(a=p.call(a,f,"$1."),a=p.call(a,d,"$1.e")),t>=0&&r.sign&&(a=r.sign+a),a=r.specifier===c.call(r.specifier)?c.call(a):o.call(a)}function b(e){var r,i="";for(r=0;r127)throw new Error("invalid character code. Value: "+t.arg);t.arg=x(o)?String(t.arg):m(o)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(t.precision=6),t.arg=v(t);break;default:throw new Error("invalid specifier: "+t.specifier)}t.maxWidth>=0&&t.arg.length>t.maxWidth&&(t.arg=t.arg.substring(0,t.maxWidth)),t.padZeros?t.arg=i(t.arg,t.width||t.precision,t.padRight):t.width&&(t.arg=(f=t.arg,d=t.width,h=t.padRight,u=void 0,(u=d-f.length)<0?f:f=h?f+b(u):b(u)+f)),c+=t.arg||"",p+=1}return c}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function $(e){var r={mapping:e[1]?parseInt(e[1],10):void 0,flags:e[2],width:e[3],precision:e[5],specifier:e[6]};return"."===e[4]&&void 0===e[5]&&(r.precision="1"),r}function F(e){var r,i,a,t;for(i=[],t=0,a=S.exec(e);a;)(r=e.slice(t,S.lastIndex-a[0].length)).length&&i.push(r),i.push($(a)),t=S.lastIndex,a=S.exec(e);return(r=e.slice(t)).length&&i.push(r),i}function I(e){var r,i;if("string"!=typeof e)throw new TypeError(I("1Of3F",e));for(r=[F(e)],i=1;i 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\ttokens.push( parse( match ) );\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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\nimport interpolate from '@stdlib/string-base-format-interpolate';\nimport tokenize from '@stdlib/string-base-format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( '1Of3F', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n"],"names":["isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","digits","f","parseFloat","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply"],"mappings":";;AAsCA,SAASA,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAA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qB,KAAML,GAEdhB,EAAOqB,KAAMR,EAAOC,IACpBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZkD,EAAOqB,KAAML,GAEPhB,CACR,CCtCA,SAASsB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI6D,UAAWgB,EAAQ,QAAS7E,IAGvC,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAImE,UAAU3D,OAAQR,IAClCiF,EAAKF,KAAMZ,UAAWnE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC","x_google_ignoreList":[0,1,2,3,4,5,6,7]} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d5a67cb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7e3335c251eb26c32cf2f727c92ad4c046841d71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 21 Jul 2025 01:05:14 +0000 Subject: [PATCH 159/159] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 187 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 24 +- SECURITY.md | 5 - benchmark/benchmark.js | 73 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 31 - docs/types/test.ts | 45 - examples/index.js | 41 - lib/index.js | 43 - lib/is_string.js | 42 - lib/main.js | 64 - docs/types/index.d.ts => mod.d.ts | 0 mod.js | 4 + mod.js.map | 1 + package.json | 56 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 1092 ---- 45 files changed, 4852 insertions(+), 5088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 lib/index.js delete mode 100644 lib/is_string.js delete mode 100644 lib/main.js rename docs/types/index.d.ts => mod.d.ts (100%) create mode 100644 mod.js create mode 100644 mod.js.map create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -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/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c80dfac..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-07-21T01:00:20.067Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 758f430..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 58e76a6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index d4b596e..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '31 7 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # 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: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index acf1714..0000000 --- a/test/test.js +++ /dev/null @@ -1,1092 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PI = require( '@stdlib/constants-float64-pi' ); -var PINF = require( '@stdlib/constants-float64-pinf' ); -var NINF = require( '@stdlib/constants-float64-ninf' ); -var format = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof format, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a primitive string', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - null, - void 0, - true, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value ); - }; - } -}); - -tape( 'the function throws an error if provided a format string with an invalid format specifier', function test( t ) { - var values; - var i; - - values = [ - '%C', - '%S', - '%U', - '%Z' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - format( value, 'beep' ); - }; - } -}); - -tape( 'the function returns a formatted string (`s` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%s'; - actual = format( str, 'beep' ); - expected = 'beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%s %s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6s'; - actual = format( str, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6s'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - - str = '%2s %2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, variable width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%*s'; - actual = format( str, 6, 'beep' ); - expected = ' beep'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %*s'; - actual = format( str, 6, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%*s %*s baz'; - actual = format( str, 6, 'beep', 4, 'boop' ); - expected = ' beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-6s'; - actual = format( str, 'beep' ); - expected = 'beep '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-6s'; - actual = format( str, 'boop' ); - expected = 'beep boop '; - - str = '%-2s %-2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep boop baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.2s'; - actual = format( str, 'beep' ); - expected = 'be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%6.2s'; - actual = format( str, 'beep' ); - expected = ' be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %6.2s'; - actual = format( str, 'boop' ); - expected = 'beep bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%6.8s %4.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, precision, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%06.2s'; - actual = format( str, 'beep' ); - expected = '0000be'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %06.2s'; - actual = format( str, 'boop' ); - expected = 'beep 0000bo'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%06.8s %04.2s baz'; - actual = format( str, 'beep', 'boop' ); - expected = 'beep bo00 b'; - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 70 ); - expected = 'F'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 75 ); - expected = 'beep K'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%c %c baz'; - actual = format( str, 70, 75 ); - expected = 'F K baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, string arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%c'; - actual = format( str, 'b' ); - expected = 'b'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %c'; - actual = format( str, 'boop' ); - expected = 'beep boop'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2c'; - actual = format( str, 80 ); - expected = ' P'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4c'; - actual = format( str, 90 ); - expected = 'beep Z'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2c %c baz'; - actual = format( str, 80, 90 ); - expected = ' P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`c` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2c'; - actual = format( str, 80 ); - expected = 'P '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4c'; - actual = format( str, 90 ); - expected = 'beep Z '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-2c %-c baz'; - actual = format( str, 80, 90 ); - expected = 'P Z baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%d'; - actual = format( str, 3 ); - expected = '3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %d'; - actual = format( str, 5.8 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%d %d baz'; - actual = format( str, 3, 5 ); - expected = '3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, sign)', function test( t ) { - var expected; - var actual; - var str; - - str = '%+d'; - actual = format( str, 3 ); - expected = '+3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %+d'; - actual = format( str, 5.8 ); - expected = 'beep +5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, 3, 5 ); - expected = '+3 +5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%+d %+d baz'; - actual = format( str, -3, -5 ); - expected = '-3 -5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2d'; - actual = format( str, 3 ); - expected = ' 3'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %4d'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2d %d baz'; - actual = format( str, 3.1, 5 ); - expected = ' 3 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-2d'; - actual = format( str, 3 ); - expected = '3 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-4d'; - actual = format( str, 5.2 ); - expected = 'beep 5 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-3d baz'; - actual = format( str, 3, 5 ); - expected = '3 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`d` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%02d'; - actual = format( str, 3 ); - expected = '03'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %04d'; - actual = format( str, 5.1 ); - expected = 'beep 0005'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%02d %d baz'; - actual = format( str, 3, 5 ); - expected = '03 5 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%f'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f %f baz'; - actual = format( str, PINF, NINF ); - expected = 'infinity -infinity baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%f'; - actual = format( str, NaN ); - expected = 'nan'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`F` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%F'; - actual = format( str, 3.14 ); - expected = '3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %F'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140000 5.000000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F %F baz'; - actual = format( str, PINF, NINF ); - expected = 'INFINITY -INFINITY baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%F'; - actual = format( str, NaN ); - expected = 'NAN'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, specified precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, variable precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.*f'; - actual = format( str, 3, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.*f'; - actual = format( str, 3, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.*f %.*f baz'; - actual = format( str, 3, PI, 3, PI ); - expected = '3.142 3.142 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`g` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%g'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %g'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032e-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%g %g baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032e-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3.G'; - actual = format( str, 100 ); - expected = '1E+02'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%G %G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`G` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#G'; - actual = format( str, PI ); - expected = '3.14159'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#3.G'; - actual = format( str, 100 ); - expected = '1.E+02'; // always contains a decimal point! - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#G'; - actual = format( str, 1.0003212e-10 ); - expected = 'beep 1.00032E-10'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#G %#G baz'; - actual = format( str, PI, 1.0003212e-10 ); - expected = '3.14159 1.00032E-10 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12f'; - actual = format( str, 3.14 ); - expected = ' 3.140000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%.3f'; - actual = format( str, 3.14 ); - expected = '3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%.3f'; - actual = format( str, PI ); - expected = '3.142'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%8.3f'; - actual = format( str, 3.14 ); - expected = ' 3.140'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = ' 3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`f` specifier, minimum width, left-justified, decimal precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-8.3f'; - actual = format( str, 3.14 ); - expected = '3.140 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-8.3f'; - actual = format( str, 5.0 ); - expected = 'beep 5.000 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%-8.3f %.3f baz'; - actual = format( str, 3.14, 5.0 ); - expected = '3.140 5.000 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%b %b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#b'; - actual = format( str, 3 ); - expected = '11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#b %#b baz'; - actual = format( str, 3, 5 ); - expected = '11 101 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12b'; - actual = format( str, 3 ); - expected = ' 11'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12b'; - actual = format( str, 5 ); - expected = 'beep 101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, left-justified)', function test( t ) { - var expected; - var actual; - var str; - - str = '%-12b'; - actual = format( str, 3 ); - expected = '11 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %-12b'; - actual = format( str, 5 ); - expected = 'beep 101 '; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`b` specifier, minimum width, zero-padded)', function test( t ) { - var expected; - var actual; - var str; - - str = '%012b'; - actual = format( str, 3 ); - expected = '000000000011'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %012b'; - actual = format( str, 5 ); - expected = 'beep 000000000101'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%o'; - actual = format( str, 12 ); - expected = '14'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %o'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%o %o baz'; - actual = format( str, 8, 9 ); - expected = '10 11 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`o` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#o'; - actual = format( str, 12 ); - expected = '014'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#o'; - actual = format( str, 5 ); - expected = 'beep 05'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#o %#o baz'; - actual = format( str, 8, 9 ); - expected = '010 011 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%x'; - actual = format( str, 12 ); - expected = 'c'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %x'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%x %x baz'; - actual = format( str, 14, 15 ); - expected = 'e f baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`x` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#x'; - actual = format( str, 12 ); - expected = '0xc'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#x'; - actual = format( str, 5 ); - expected = 'beep 0x5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#x %#x baz'; - actual = format( str, 14, 15 ); - expected = '0xe 0xf baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%X'; - actual = format( str, 12 ); - expected = 'C'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %X'; - actual = format( str, 5 ); - expected = 'beep 5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%X %X baz'; - actual = format( str, 14, 15 ); - expected = 'E F baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`X` specifier, alternate form)', function test( t ) { - var expected; - var actual; - var str; - - str = '%#X'; - actual = format( str, 12 ); - expected = '0XC'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %#X'; - actual = format( str, 5 ); - expected = 'beep 0X5'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%#X %#X baz'; - actual = format( str, 14, 15 ); - expected = '0XE 0XF baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`u` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%u'; - actual = format( str, 12 ); - expected = '12'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %u'; - actual = format( str, -5 ); - expected = 'beep 4294967291'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%u %u baz'; - actual = format( str, 14, 15 ); - expected = '14 15 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%e'; - actual = format( str, 12 ); - expected = '1.200000e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %e'; - actual = format( str, -5 ); - expected = 'beep -5.000000e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%e %e baz'; - actual = format( str, 14, 15 ); - expected = '1.400000e+01 1.500000e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`e` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2e'; - actual = format( str, 12 ); - expected = ' 1.20e+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2e'; - actual = format( str, -5 ); - expected = 'beep -5.00e+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2e %12.2e baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40e+01 1.50e+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier)', function test( t ) { - var expected; - var actual; - var str; - - str = '%E'; - actual = format( str, 12 ); - expected = '1.200000E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %E'; - actual = format( str, -5 ); - expected = 'beep -5.000000E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%E %E baz'; - actual = format( str, 14, 15 ); - expected = '1.400000E+01 1.500000E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`E` specifier, minimum width, precision)', function test( t ) { - var expected; - var actual; - var str; - - str = '%12.2E'; - actual = format( str, 12 ); - expected = ' 1.20E+01'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = 'beep %12.2E'; - actual = format( str, -5 ); - expected = 'beep -5.00E+00'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%12.2E %12.2E baz'; - actual = format( str, 14, 15 ); - expected = ' 1.40E+01 1.50E+01 baz'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); - -tape( 'the function returns a formatted string (`s` specifier, positional arguments)', function test( t ) { - var expected; - var actual; - var str; - - str = '%2$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%2$s %1$s %1$s!'; - actual = format( str, 'World', 'Hello' ); - expected = 'Hello World World!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - str = '%3$s %2$s %1$s!'; - actual = format( str, 'C', 'B', 'A' ); - expected = 'A B C!'; - t.strictEqual( actual, expected, 'returns expected output' ); - - t.end(); -}); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy