Socket
Socket
Sign inDemoInstall

string.format

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string.format - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

16

index.js

@@ -11,5 +11,19 @@ /* jslint node: true */

function format(string,params){
var replaced = string.replace(/\{([a-z0-9\$\_]+(?:\.[a-z0-9\-\_]+)*)\}/gmi,function(match,capture,index,all){
var replaced = string;
replaced = replaced.replace(/\·\{(.*)\}\·/gmi,function(match,capture,index,all){
var replace;
try {
replace = eval(capture);
replace = JSON.decycled(replace);
if(typeof replace === 'string'){
replace = replace.replace(/(^\"|\"$)/g,'').replace(/(\\n|\\r)/g,'\n').replace(/\\t/g,'\t');
}
return replace;
} catch(error){
return match;
}
});
replaced = replaced.replace(/\{([a-z0-9\$\_]+(?:\.[a-z0-9\-\_]+)*)\}/gmi,function(match,capture,index,all){
var replace;
try {
capture = '["'+capture.split('.').join('"]["')+'"]';

@@ -16,0 +30,0 @@ replace = eval('params'+capture);

2

package.json
{
"name": "string.format",
"description": "String prototype method -> 'Hello {name}!'.format({name:'Homer'});",
"version": "1.1.0",
"version": "1.2.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Bifuer",

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