Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sprintf-js

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sprintf-js - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

.editorconfig

8

bower.json

@@ -5,3 +5,6 @@ {

"version": "1.0.3",
"main": "src/sprintf.js",
"main": [
"dist/sprintf.min.js",
"dist/angular-sprintf.min.js"
],
"license": "BSD-3-Clause-Clear",

@@ -14,3 +17,4 @@ "keywords": ["sprintf", "string", "formatting"],

"url": "git://github.com/alexei/sprintf.js.git"
}
},
"ignore": []
}

@@ -1,4 +0,3 @@

/*! sprintf-js | Alexandru Marasteanu <hello@alexei.ro> (http://alexei.ro/) | BSD-3-Clause */
angular.module("sprintf",[]).filter("sprintf",function(){return function(){return sprintf.apply(null,arguments)}}).filter("fmt",["$filter",function(a){return a("sprintf")}]).filter("vsprintf",function(){return function(a,b){return vsprintf(a,b)}}).filter("vfmt",["$filter",function(a){return a("vsprintf")}]);
//# sourceMappingURL=angular-sprintf.min.map
/*! sprintf-js v1.1.0 | Copyright (c) 2007-present, Alexandru Marasteanu <hello@alexei.ro> | BSD-3-Clause */
!function(){"use strict";angular.module("sprintf",[]).filter("sprintf",function(){return function(){return sprintf.apply(null,arguments)}}).filter("fmt",["$filter",function(t){return t("sprintf")}]).filter("vsprintf",function(){return function(t,n){return vsprintf(t,n)}}).filter("vfmt",["$filter",function(t){return t("vsprintf")}])}();
//# sourceMappingURL=angular-sprintf.min.js.map

@@ -1,4 +0,3 @@

/*! sprintf-js | Alexandru Marasteanu <hello@alexei.ro> (http://alexei.ro/) | BSD-3-Clause */
!function(a){function b(){var a=arguments[0],c=b.cache;return c[a]&&c.hasOwnProperty(a)||(c[a]=b.parse(a)),b.format.call(null,c[a],arguments)}function c(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function d(a,b){return Array(b+1).join(a)}var e={not_string:/[^s]/,number:/[diefg]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};b.format=function(a,f){var g,h,i,j,k,l,m,n=1,o=a.length,p="",q=[],r=!0,s="";for(h=0;o>h;h++)if(p=c(a[h]),"string"===p)q[q.length]=a[h];else if("array"===p){if(j=a[h],j[2])for(g=f[n],i=0;i<j[2].length;i++){if(!g.hasOwnProperty(j[2][i]))throw new Error(b("[sprintf] property '%s' does not exist",j[2][i]));g=g[j[2][i]]}else g=j[1]?f[j[1]]:f[n++];if("function"==c(g)&&(g=g()),e.not_string.test(j[8])&&e.not_json.test(j[8])&&"number"!=c(g)&&isNaN(g))throw new TypeError(b("[sprintf] expecting number but found %s",c(g)));switch(e.number.test(j[8])&&(r=g>=0),j[8]){case"b":g=g.toString(2);break;case"c":g=String.fromCharCode(g);break;case"d":case"i":g=parseInt(g,10);break;case"j":g=JSON.stringify(g,null,j[6]?parseInt(j[6]):0);break;case"e":g=j[7]?g.toExponential(j[7]):g.toExponential();break;case"f":g=j[7]?parseFloat(g).toFixed(j[7]):parseFloat(g);break;case"g":g=j[7]?parseFloat(g).toPrecision(j[7]):parseFloat(g);break;case"o":g=g.toString(8);break;case"s":g=(g=String(g))&&j[7]?g.substring(0,j[7]):g;break;case"u":g>>>=0;break;case"x":g=g.toString(16);break;case"X":g=g.toString(16).toUpperCase()}e.json.test(j[8])?q[q.length]=g:(!e.number.test(j[8])||r&&!j[3]?s="":(s=r?"+":"-",g=g.toString().replace(e.sign,"")),l=j[4]?"0"===j[4]?"0":j[4].charAt(1):" ",m=j[6]-(s+g).length,k=j[6]&&m>0?d(l,m):"",q[q.length]=j[5]?s+g+k:"0"===l?s+k+g:k+s+g)}return q.join("")},b.cache={},b.parse=function(a){for(var b=a,c=[],d=[],f=0;b;){if(null!==(c=e.text.exec(b)))d[d.length]=c[0];else if(null!==(c=e.modulo.exec(b)))d[d.length]="%";else{if(null===(c=e.placeholder.exec(b)))throw new SyntaxError("[sprintf] unexpected placeholder");if(c[2]){f|=1;var g=[],h=c[2],i=[];if(null===(i=e.key.exec(h)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(g[g.length]=i[1];""!==(h=h.substring(i[0].length));)if(null!==(i=e.key_access.exec(h)))g[g.length]=i[1];else{if(null===(i=e.index_access.exec(h)))throw new SyntaxError("[sprintf] failed to parse named argument key");g[g.length]=i[1]}c[2]=g}else f|=2;if(3===f)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d[d.length]=c}b=b.substring(c[0].length)}return d};var f=function(a,c,d){return d=(c||[]).slice(0),d.splice(0,0,a),b.apply(null,d)};"undefined"!=typeof exports?(exports.sprintf=b,exports.vsprintf=f):(a.sprintf=b,a.vsprintf=f,"function"==typeof define&&define.amd&&define(function(){return{sprintf:b,vsprintf:f}}))}("undefined"==typeof window?this:window);
//# sourceMappingURL=sprintf.min.map
/*! sprintf-js v1.1.0 | Copyright (c) 2007-present, Alexandru Marasteanu <hello@alexei.ro> | BSD-3-Clause */
!function(e){"use strict";function t(){var e=arguments[0],r=t.cache;return r[e]||(r[e]=t.parse(e)),t.format.call(null,r[e],arguments)}function r(e){return"number"==typeof e?"number":"string"==typeof e?"string":Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function n(e,t){return t>=0&&t<=7&&i[e]?i[e][t]:Array(t+1).join(e)}var s={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};t.format=function(e,a){var i,o,l,c,p,f,u,g=1,_=e.length,d="",b=[],h=!0,x="";for(o=0;o<_;o++)if("string"===(d=r(e[o])))b[b.length]=e[o];else if("array"===d){if(c=e[o],c[2])for(i=a[g],l=0;l<c[2].length;l++){if(!i.hasOwnProperty(c[2][l]))throw new Error(t('[sprintf] property "%s" does not exist',c[2][l]));i=i[c[2][l]]}else i=c[1]?a[c[1]]:a[g++];if(s.not_type.test(c[8])&&s.not_primitive.test(c[8])&&"function"==r(i)&&(i=i()),s.numeric_arg.test(c[8])&&"number"!=r(i)&&isNaN(i))throw new TypeError(t("[sprintf] expecting number but found %s",r(i)));switch(s.number.test(c[8])&&(h=i>=0),c[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,c[6]?parseInt(c[6]):0);break;case"e":i=c[7]?parseFloat(i).toExponential(c[7]):parseFloat(i).toExponential();break;case"f":i=c[7]?parseFloat(i).toFixed(c[7]):parseFloat(i);break;case"g":i=c[7]?parseFloat(i).toPrecision(c[7]):parseFloat(i);break;case"o":i=i.toString(8);break;case"s":i=String(i),i=c[7]?i.substring(0,c[7]):i;break;case"t":i=String(!!i),i=c[7]?i.substring(0,c[7]):i;break;case"T":i=r(i),i=c[7]?i.substring(0,c[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=c[7]?i.substring(0,c[7]):i;break;case"x":i=parseInt(i,10).toString(16);break;case"X":i=parseInt(i,10).toString(16).toUpperCase()}s.json.test(c[8])?b[b.length]=i:(!s.number.test(c[8])||h&&!c[3]?x="":(x=h?"+":"-",i=i.toString().replace(s.sign,"")),f=c[4]?"0"===c[4]?"0":c[4].charAt(1):" ",u=c[6]-(x+i).length,p=c[6]&&u>0?n(f,u):"",b[b.length]=c[5]?x+i+p:"0"===f?x+p+i:p+x+i)}return b.join("")},t.cache=Object.create(null),t.parse=function(e){for(var t=e,r=[],n=[],a=0;t;){if(null!==(r=s.text.exec(t)))n[n.length]=r[0];else if(null!==(r=s.modulo.exec(t)))n[n.length]="%";else{if(null===(r=s.placeholder.exec(t)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){a|=1;var i=[],o=r[2],l=[];if(null===(l=s.key.exec(o)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(i[i.length]=l[1];""!==(o=o.substring(l[0].length));)if(null!==(l=s.key_access.exec(o)))i[i.length]=l[1];else{if(null===(l=s.index_access.exec(o)))throw new SyntaxError("[sprintf] failed to parse named argument key");i[i.length]=l[1]}r[2]=i}else a|=2;if(3===a)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}t=t.substring(r[0].length)}return n};var a=function(e,r,n){return n=(r||[]).slice(0),n.splice(0,0,e),t.apply(null,n)},i={0:["","0","00","000","0000","00000","000000","0000000"]," ":[""," "," "," "," "," "," "," "],_:["","_","__","___","____","_____","______","_______"]};"undefined"!=typeof exports&&(exports.sprintf=t,exports.vsprintf=a),void 0!==e&&(e.sprintf=t,e.vsprintf=a,"function"==typeof define&&define.amd&&define(function(){return{sprintf:t,vsprintf:a}}))}("undefined"==typeof window?this:window);
//# sourceMappingURL=sprintf.min.js.map
{
"name": "sprintf-js",
"version": "1.0.3",
"description": "JavaScript sprintf implementation",
"author": "Alexandru Marasteanu <hello@alexei.ro> (http://alexei.ro/)",
"main": "src/sprintf.js",
"scripts": {
"test": "mocha test/test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/alexei/sprintf.js.git"
},
"license": "BSD-3-Clause",
"readmeFilename": "README.md",
"devDependencies": {
"mocha": "*",
"grunt": "*",
"grunt-contrib-watch": "*",
"grunt-contrib-uglify": "*"
}
"name": "sprintf-js",
"version": "1.1.0",
"description": "JavaScript sprintf implementation",
"author": "Alexandru Marasteanu <hello@alexei.ro>",
"main": "src/sprintf.js",
"scripts": {
"test": "mocha test/test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/alexei/sprintf.js.git"
},
"license": "BSD-3-Clause",
"readmeFilename": "README.md",
"devDependencies": {
"benchmark": "^2.1.4",
"gulp": "^3.9.0",
"gulp-benchmark": "^1.1.1",
"gulp-header": "^1.7.1",
"gulp-jshint": "^2.0.0",
"gulp-mocha": "^4.3.1",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^2.6.0",
"gulp-uglify": "^2.1.2",
"jshint": "^2.9.1",
"mocha": "^3.3.0"
}
}

@@ -1,2 +0,12 @@

# sprintf.js
# sprintf.js [![NPM Version][npm-image]][npm-url] [![Dependency Status][dependencies-image]][dependencies-url] [![devDependency Status][dev-dependencies-image]][dev-dependencies-url]
[npm-image]: https://badge.fury.io/js/sprintf-js.svg
[npm-url]: https://badge.fury.io/js/sprintf-js
[dependencies-image]: https://david-dm.org/alexei/sprintf.js.svg
[dependencies-url]: https://david-dm.org/alexei/sprintf.js
[dev-dependencies-image]: https://david-dm.org/alexei/sprintf.js/dev-status.svg
[dev-dependencies-url]: https://david-dm.org/alexei/sprintf.js#info=devDependencies
**sprintf.js** is a complete open source JavaScript sprintf implementation for the *browser* and *node.js*.

@@ -27,2 +37,5 @@

* `s` — yields a string as is
* `t` — yields `true` or `false`
* `T` — yields the type of the argument<sup><a href="#fn-1" name="fn-ref-1">1</a></sup>
* `v` — yields the primitive value of the specified argument
* `x` — yields an integer as a hexadecimal number (lower-case)

@@ -32,2 +45,3 @@ * `X` — yields an integer as a hexadecimal number (upper-case)

## JavaScript `vsprintf`

@@ -91,1 +105,5 @@ `vsprintf` is the same as `sprintf` except that it accepts an array of arguments, rather than a variable number of arguments:

**sprintf.js** is licensed under the terms of the 3-clause BSD license.
# Notes
<small><sup><a href="#fn-ref-1" name="fn-1">1</a></sup> `sprintf` doesn't use the `typeof` operator. As such, the value `null` is a `null`, an array is an `array` (not an `object`), a date value is a `date` etc.</small>

@@ -1,18 +0,24 @@

angular.
module("sprintf", []).
filter("sprintf", function() {
return function() {
return sprintf.apply(null, arguments)
}
}).
filter("fmt", ["$filter", function($filter) {
return $filter("sprintf")
}]).
filter("vsprintf", function() {
return function(format, argv) {
return vsprintf(format, argv)
}
}).
filter("vfmt", ["$filter", function($filter) {
return $filter("vsprintf")
}])
/* globals angular, sprintf, vsprintf */
(function () {
'use strict'
angular.
module('sprintf', []).
filter('sprintf', function() {
return function() {
return sprintf.apply(null, arguments)
}
}).
filter('fmt', ['$filter', function($filter) {
return $filter('sprintf')
}]).
filter('vsprintf', function() {
return function(format, argv) {
return vsprintf(format, argv)
}
}).
filter('vfmt', ['$filter', function($filter) {
return $filter('vsprintf')
}])
})();

@@ -0,5 +1,13 @@

/* globals window, exports, define */
(function(window) {
'use strict'
var re = {
not_string: /[^s]/,
not_bool: /[^t]/,
not_type: /[^T]/,
not_primitive: /[^v]/,
number: /[diefg]/,
numeric_arg: /[bcdiefguxX]/,
json: /[j]/,

@@ -9,3 +17,3 @@ not_json: /[^j]/,

modulo: /^\x25{2}/,
placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,
placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
key: /^([a-z_][a-z_\d]*)/i,

@@ -19,3 +27,3 @@ key_access: /^\.([a-z_][a-z_\d]*)/i,

var key = arguments[0], cache = sprintf.cache
if (!(cache[key] && cache.hasOwnProperty(key))) {
if (!(cache[key])) {
cache[key] = sprintf.parse(key)

@@ -27,9 +35,9 @@ }

sprintf.format = function(parse_tree, argv) {
var cursor = 1, tree_length = parse_tree.length, node_type = "", arg, output = [], i, k, match, pad, pad_character, pad_length, is_positive = true, sign = ""
var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length, is_positive = true, sign = ''
for (i = 0; i < tree_length; i++) {
node_type = get_type(parse_tree[i])
if (node_type === "string") {
if (node_type === 'string') {
output[output.length] = parse_tree[i]
}
else if (node_type === "array") {
else if (node_type === 'array') {
match = parse_tree[i] // convenience purposes only

@@ -40,3 +48,3 @@ if (match[2]) { // keyword argument

if (!arg.hasOwnProperty(match[2][k])) {
throw new Error(sprintf("[sprintf] property '%s' does not exist", match[2][k]))
throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k]))
}

@@ -53,7 +61,7 @@ arg = arg[match[2][k]]

if (get_type(arg) == "function") {
if (re.not_type.test(match[8]) && re.not_primitive.test(match[8]) && get_type(arg) == 'function') {
arg = arg()
}
if (re.not_string.test(match[8]) && re.not_json.test(match[8]) && (get_type(arg) != "number" && isNaN(arg))) {
if (re.numeric_arg.test(match[8]) && (get_type(arg) != 'number' && isNaN(arg))) {
throw new TypeError(sprintf("[sprintf] expecting number but found %s", get_type(arg)))

@@ -67,39 +75,52 @@ }

switch (match[8]) {
case "b":
arg = arg.toString(2)
case 'b':
arg = parseInt(arg, 10).toString(2)
break
case "c":
arg = String.fromCharCode(arg)
case 'c':
arg = String.fromCharCode(parseInt(arg, 10))
break
case "d":
case "i":
case 'd':
case 'i':
arg = parseInt(arg, 10)
break
case "j":
case 'j':
arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0)
break
case "e":
arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential()
case 'e':
arg = match[7] ? parseFloat(arg).toExponential(match[7]) : parseFloat(arg).toExponential()
break
case "f":
case 'f':
arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)
break
case "g":
case 'g':
arg = match[7] ? parseFloat(arg).toPrecision(match[7]) : parseFloat(arg)
break
case "o":
case 'o':
arg = arg.toString(8)
break
case "s":
arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg)
case 's':
arg = String(arg)
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
case "u":
arg = arg >>> 0
case 't':
arg = String(!!arg)
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
case "x":
arg = arg.toString(16)
case 'T':
arg = get_type(arg)
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
case "X":
arg = arg.toString(16).toUpperCase()
case 'u':
arg = parseInt(arg, 10) >>> 0
break
case 'v':
arg = arg.valueOf()
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
case 'x':
arg = parseInt(arg, 10).toString(16)
break
case 'X':
arg = parseInt(arg, 10).toString(16).toUpperCase()
break
}

@@ -111,19 +132,19 @@ if (re.json.test(match[8])) {

if (re.number.test(match[8]) && (!is_positive || match[3])) {
sign = is_positive ? "+" : "-"
arg = arg.toString().replace(re.sign, "")
sign = is_positive ? '+' : '-'
arg = arg.toString().replace(re.sign, '')
}
else {
sign = ""
sign = ''
}
pad_character = match[4] ? match[4] === "0" ? "0" : match[4].charAt(1) : " "
pad_character = match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' '
pad_length = match[6] - (sign + arg).length
pad = match[6] ? (pad_length > 0 ? str_repeat(pad_character, pad_length) : "") : ""
output[output.length] = match[5] ? sign + arg + pad : (pad_character === "0" ? sign + pad + arg : pad + sign + arg)
pad = match[6] ? (pad_length > 0 ? str_repeat(pad_character, pad_length) : '') : ''
output[output.length] = match[5] ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)
}
}
}
return output.join("")
return output.join('')
}
sprintf.cache = {}
sprintf.cache = Object.create(null)

@@ -137,3 +158,3 @@ sprintf.parse = function(fmt) {

else if ((match = re.modulo.exec(_fmt)) !== null) {
parse_tree[parse_tree.length] = "%"
parse_tree[parse_tree.length] = '%'
}

@@ -146,3 +167,3 @@ else if ((match = re.placeholder.exec(_fmt)) !== null) {

field_list[field_list.length] = field_match[1]
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") {
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
if ((field_match = re.key_access.exec(replacement_field)) !== null) {

@@ -190,6 +211,22 @@ field_list[field_list.length] = field_match[1]

function get_type(variable) {
return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase()
if (typeof variable === 'number') {
return 'number'
}
else if (typeof variable === 'string') {
return 'string'
}
else {
return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase()
}
}
var preformattedPadding = {
'0': ['', '0', '00', '000', '0000', '00000', '000000', '0000000'],
' ': ['', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
'_': ['', '_', '__', '___', '____', '_____', '______', '_______'],
}
function str_repeat(input, multiplier) {
if (multiplier >= 0 && multiplier <= 7 && preformattedPadding[input]) {
return preformattedPadding[input][multiplier]
}
return Array(multiplier + 1).join(input)

@@ -201,11 +238,11 @@ }

*/
if (typeof exports !== "undefined") {
if (typeof exports !== 'undefined') {
exports.sprintf = sprintf
exports.vsprintf = vsprintf
}
else {
if (typeof window !== 'undefined') {
window.sprintf = sprintf
window.vsprintf = vsprintf
if (typeof define === "function" && define.amd) {
if (typeof define === 'function' && define.amd) {
define(function() {

@@ -219,2 +256,2 @@ return {

}
})(typeof window === "undefined" ? this : window);
})(typeof window === 'undefined' ? this : window);

@@ -0,1 +1,3 @@

'use strict';
var assert = require("assert"),

@@ -30,2 +32,27 @@ sprintfjs = require("../src/sprintf.js"),

assert.equal("Hello world!", sprintf("Hello %(who)s!", {"who": "world"}))
assert.equal("true", sprintf("%t", true))
assert.equal("t", sprintf("%.1t", true))
assert.equal("true", sprintf("%t", "true"))
assert.equal("true", sprintf("%t", 1))
assert.equal("false", sprintf("%t", false))
assert.equal("f", sprintf("%.1t", false))
assert.equal("false", sprintf("%t", ""))
assert.equal("false", sprintf("%t", 0))
assert.equal('undefined', sprintf('%T', undefined))
assert.equal('null', sprintf('%T', null))
assert.equal('boolean', sprintf('%T', true))
assert.equal('number', sprintf('%T', 42))
assert.equal('string', sprintf('%T', "This is a string"))
assert.equal('function', sprintf('%T', Math.log))
assert.equal('array', sprintf('%T', [1, 2, 3]))
assert.equal('object', sprintf('%T', {foo: 'bar'}))
assert.equal('regexp', sprintf('%T', /<("[^"]*"|'[^']*'|[^'">])*>/))
assert.equal('true', sprintf('%v', true))
assert.equal('42', sprintf('%v', 42))
assert.equal('This is a string', sprintf('%v', "This is a string"))
assert.equal('1,2,3', sprintf('%v', [1, 2, 3]))
assert.equal('[object Object]', sprintf('%v', {foo: 'bar'}))
assert.equal('/<("[^"]*"|\'[^\']*\'|[^\'">])*>/', sprintf('%v', /<("[^"]*"|'[^']*'|[^'">])*>/))
})

@@ -32,0 +59,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc