Gathering detailed insights and metrics for @debonet/es6format
Gathering detailed insights and metrics for @debonet/es6format
npm install @debonet/es6format
Typescript
Module System
Node Version
NPM Version
64
Supply Chain
95.9
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
256
Last Day
1
Last Week
2
Last Month
3
Last Year
47
3 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
@debonet/es6format@1.0.1
Unpacked Size
5.32 kB
Size
2.56 kB
File Count
4
NPM Version
8.15.0
Node Version
18.7.0
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
-50%
3
Compared to previous month
Last year
-45.3%
47
Compared to previous year
No dependencies detected.
String formatting that replicates the ES6 template operator but executes at runtime.
1 npm install es6format
1 const format = require( "es6format" ); 2 console.log( 3 format( "Hello, ${0}!", "World" ) 4 ); 5 // output: Hello, World! 6 7 format.bindTo( String, 'using' ); 8 console.log( 9 "Hello, ${0}!".using( "World" ) 10 ); 11 // output: Hello, World!
Usage is straightforward:
1 format( <template-string>, ...args )
Arguments passed to the function are made available to the template via the following ways:
${0}
to reference arugments by order
1 format( "Hello, ${0}!", "World" );
${name}
to reference any fields of arguments
1 format( "Call me ${name}.", { name : "Ishmael" });
NOTE: in cases where multiple arguments include the same field, the last argument takes precidence. Use fully defined object references to get access to the others. See below
1 format( 2 "Don't call me ${name}.", 3 { name : "Ishmael" }, 4 { name : "Bob"} 5 );
${arg1}
to use arguments within expressions or to access argument fields. Particularly handy to disambiguate fields when multiple arguments have them (e.g. ${arg2.name}
)
1 format( 2 "Using ${name} gives you ${arg1.name} not ${arg0.name}", 3 { name : "Ishmael" }, 4 { name : "Bob"} 5 );
to use the argument in a function
1 format( "B is letter ${arg0.indexOf('B')} letter", "ABC" );
${a + b}
1 format( "the sum of ${a} and ${b} is ${a + b}", {a: 2, b: 5} );
${arg3.method()}
1 format( "Please don't ${arg0.toLowerCase()}", "YELL" );
${args[3]}
to reference arugments programatically (e.g. ${args[arg0]})
1 format( "I am ${args[arg0]}", 1, "right", "wrong" )
${x=3}
to set values for use later in the format string (e.g. ${x=a+3})
1 format( 2 "${arg0}^2 is ${x=arg0*arg0}, and squared again is ${x*x}", 3 3 4 )
${ ...some computation }
or ${ ...some computation, 'output' }
1 format( 2 "my favorite mice are ${ args.join(' mouse, ') }", 3 "Mickey", "Minie", "Mighty" 4 )
and
1 format( 2 "the password is a ${ arg0.substring( arg0.indexOf( '{' ) + 1, arg0.indexOf( '}' ))}", 3 "hidden{secret}within" 4 )
and
1 format( 2 "x.a is ${ x = { a : arg0 + arg1 }, 'set' } to ${x.a}", 3 2, 3 4 )
and even,
1 format( 2 "${args.reduce((o,i)=>{if (o<3) return o+i; return i})}", 3 1,2,3,4,5,6,7 4 )
es6format makes use of Function(), so it should never be called on format strings that are not known to be safe.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/3 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More