Comparing version 1.0.0 to 1.0.1
@@ -60,4 +60,6 @@ "use strict"; | ||
if (argsv === void 0) { argsv = []; } | ||
return sprintfv([format].concat(argsv)); | ||
var args = [format]; | ||
Array.prototype.push.apply(args, argsv); | ||
return sprintfv(args); | ||
} | ||
exports.vsprintf = vsprintf; |
@@ -5,3 +5,3 @@ { | ||
"repository": "joseluisq/sprintfit", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -29,4 +29,7 @@ "author": { | ||
"devDependencies": { | ||
"@types/benchmark": "^1.0.31", | ||
"@types/jasmine": "^2.8.8", | ||
"@types/node": "^10.5.3", | ||
"@types/node": "^10.5.4", | ||
"@types/sprintf-js": "^1.1.0", | ||
"benchmark": "^2.1.4", | ||
"jasmine": "^3.1.0", | ||
@@ -36,2 +39,3 @@ "jasmine-core": "^3.1.0", | ||
"karma": "^2.0.5", | ||
"karma-benchmark-reporter": "^0.1.1", | ||
"karma-chrome-launcher": "^2.2.0", | ||
@@ -42,6 +46,9 @@ "karma-jasmine": "^1.1.2", | ||
"karma-typescript": "^3.0.13", | ||
"printj": "^1.1.2", | ||
"rollup": "^0.63.4", | ||
"rollup-plugin-terser": "^1.0.1", | ||
"rollup-plugin-typescript2": "^0.16.1", | ||
"sprintf-js": "^1.1.1", | ||
"terser": "^3.8.1", | ||
"ts-node": "^7.0.0", | ||
"tslint": "^5.11.0", | ||
@@ -61,4 +68,5 @@ "tslint-config-standard-plus": "^2.0.0", | ||
"test:watch": "env NODE_ENV=debug karma start", | ||
"benchmark": "env NODE_ENV=development node benchmark.js", | ||
"lint": "tslint --format stylish --project tsconfig.json" | ||
} | ||
} |
# Sprintfit [![Build Status](https://travis-ci.org/joseluisq/sprintfit.svg?branch=master)](https://travis-ci.org/joseluisq/sprintfit) [![npm](https://img.shields.io/npm/v/sprintfit.svg)](https://www.npmjs.com/package/sprintfit) [![npm](https://img.shields.io/npm/dt/sprintfit.svg)](https://www.npmjs.com/package/sprintfit) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) | ||
> Small sprintf and vsprintf format specifier focused on strings. | ||
> Small sprintf and vsprintf format specifier focused on strings. :zap: | ||
__:information_source: Notice:__ `sprintf` and `vsprintf` will treat their arguments as strings only. If you are looking for the full specification you could try [sprintf.js](https://github.com/alexei/sprintf.js) or [printj](https://github.com/SheetJS/printj). | ||
*__:information_source: Notice:__ `sprintf` and `vsprintf` will treat their arguments as strings only. If you are looking for the full specification you could try [sprintf.js](https://github.com/alexei/sprintf.js) or [printj](https://github.com/SheetJS/printj).* | ||
@@ -49,6 +49,41 @@ ## Install | ||
vsprintf('date: %s-%s-%s', [2018, 07, 28]) | ||
vsprintf('date: %s-%s-%s', [ 2018, 07, 28 ]) | ||
// date: 2018-07-28 | ||
``` | ||
### Benchmarks | ||
- Node: `v8.11.3` | ||
- [BenchmarkJS](https://benchmarkjs.com): `^2.1.4` | ||
- [Sprintf-js][2]: `^1.1.1` | ||
- [Printj][3]: `^1.1.2` | ||
```sh | ||
yarn benchmark | ||
``` | ||
#### sprintf | ||
| package | ops/sec | rme | ||
--- | --- | --- | ||
[Sprintfit][1] | __2,601,688__ | ±5.19% (77 runs sampled) | ||
[SprintfJS][2] | 1,117,038 | ±1.66% (60 runs sampled) | ||
[PrintJ][3] | 1,046,954 | ±2.78% (91 runs sampled) | ||
_Done in 18.00s._ | ||
#### vsprintf | ||
| package | ops/sec | rme | ||
--- | --- | --- | ||
[Sprintfit][1] | __2,774,358__ | ±4.03% (79 runs sampled) | ||
[PrintJ][3] | 905,327 | ±3.64% (79 runs sampled) | ||
[SprintfJS][2] | 675,621 | ±7.06% (63 runs sampled) | ||
_Done in 18.34s._ | ||
[1]: https://github.com/joseluisq/sprintfit | ||
[2]: https://github.com/alexei/sprintf.js | ||
[3]: https://github.com/SheetJS/printj | ||
## Contributions | ||
@@ -55,0 +90,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.sprintfit={})}(this,function(t){"use strict";function e(t){var e=t.length,n=(t[0]||"").toString(),r=[],o=e>0?e-1:0,i=n.split("%s"),f=i.length;if(f<=0)return n;var u=f-1;if(u>o)throw new Error("Too few arguments supplied.");for(var s=0;s<e-1;++s)r.push((t[s+1]||"").toString());var p="";for(s=0;s<f;s++)p+=i[s]||"",s<u&&(p+=r[s]||"");return p}t.sprintf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e(t)},t.vsprintf=function(t,n){return void 0===t&&(t=""),void 0===n&&(n=[]),e([t].concat(n))},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.sprintfit={})}(this,function(t){"use strict";function e(t){var e=t.length,r=(t[0]||"").toString(),n=[],o=e>0?e-1:0,i=r.split("%s"),f=i.length;if(f<=0)return r;var p=f-1;if(p>o)throw new Error("Too few arguments supplied.");for(var u=0;u<e-1;++u)n.push((t[u+1]||"").toString());var s="";for(u=0;u<f;u++)s+=i[u]||"",u<p&&(s+=n[u]||"");return s}t.sprintf=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e(t)},t.vsprintf=function(t,r){void 0===t&&(t=""),void 0===r&&(r=[]);var n=[t];return Array.prototype.push.apply(n,r),e(n)},Object.defineProperty(t,"__esModule",{value:!0})}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8594
82
96
25