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

format-text

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-text - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

29

index.js
module.exports = format;
function findContext(args){
if(typeof args[1] == 'object' && args[1])
return args[1];
function format(text) {
var context;
return Array.prototype.slice.call(args, 1);
}
if (typeof arguments[1] == 'object' && arguments[1]) {
context = arguments[1];
} else {
context = Array.prototype.slice.call(arguments, 1);
}
function format(text) {
var context = findContext(arguments);
return String(text).replace(/\{?\{([^{}]+)}}?/g, replace(context));
};
function replace(context, nil){
return function(tag, name) {
if(tag.substring(0, 2) == '{{' && tag.substring(tag.length - 2) == '}}'){
function replace (context, nil){
return function (tag, name) {
if (tag.substring(0, 2) == '{{' && tag.substring(tag.length - 2) == '}}') {
return '{' + name + '}';
}
if( !context.hasOwnProperty(name) ){
if (!context.hasOwnProperty(name)) {
return tag;
}
if( typeof context[name] == 'function' ){
if (typeof context[name] == 'function') {
return context[name]();

@@ -33,5 +30,3 @@ }

return context[name];
}
}
{
"name": "format-text",
"version": "0.0.2",
"version": "0.0.3",
"description": "String formatting library inspired from Python",

@@ -5,0 +5,0 @@ "main": "index.js",

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