string.format
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -16,3 +16,5 @@ /* jslint node: true */ | ||
replace = eval('params'+capture); | ||
replace = JSON.decycled(replace).replace(/(^\"|\"$)/g,'').replace(/(\\n|\\r)/g,'\n').replace(/\\t/g,'\t'); | ||
if(typeof replace === 'string'){ | ||
replace = JSON.decycled(replace).replace(/(^\"|\"$)/g,'').replace(/(\\n|\\r)/g,'\n').replace(/\\t/g,'\t'); | ||
} | ||
return replace; | ||
@@ -19,0 +21,0 @@ } catch(error){ |
{ | ||
"name": "string.format", | ||
"description": "String prototype method -> 'Hello {name}!'.format({name:'Homer'});", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Bifuer", |
@@ -6,3 +6,8 @@ # String.format | ||
Add to [JS String.prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) `.format()` method which accepts as parameter an object or an array with values to be substituted in the string, based on a pattern. | ||
Add to [JS String.prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) `.format()` method which accepts as parameter an object or an array with values to be substituted in the string, based on a pattern. | ||
> String.format uses [JSON.decycled](https://github.com/bifuer/JSON.decycled) for show Objects as String without circular references errors and some related problems. | ||
> For Date object format you can use [Date.format](https://github.com/bifuer/Date.format) | ||
[npm](https://www.npmjs.com/package/string.format) | ||
@@ -68,5 +73,11 @@ | ||
Añade a [String.prototype de JS](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) el método `.format()` que acepta como parámetro un objeto o un array con valores que serán sustituidos en el string en base a un patrón de sustitución. [npm](https://www.npmjs.com/package/string.format) | ||
Añade a [String.prototype de JS](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) el método `.format()` que acepta como parámetro un objeto o un array con valores que serán sustituidos en el string en base a un patrón de sustitución. | ||
> String.format utiliza [JSON.decycled](https://github.com/bifuer/JSON.decycled) para monstar objetos como strings sin errores de referencia circular y otros problemas relacionados. | ||
> Para ampliar las funciones de String.format en el caso de objetos Date puede resultarte util [Date.format](https://github.com/bifuer/Date.format) | ||
[npm](https://www.npmjs.com/package/string.format) | ||
## Licencia | ||
MIT |
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
5873
23
82