Installations
npm install @debonet/es6format
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
18.7.0
NPM Version
8.15.0
Score
64
Supply Chain
95.9
Quality
75.2
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
debonet
Download Statistics
Total Downloads
256
Last Day
1
Last Week
2
Last Month
3
Last Year
47
GitHub Statistics
3 Commits
1 Watching
1 Branches
1 Contributors
Bundle Size
497.00 B
Minified
335.00 B
Minified + Gzipped
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
256
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No dependencies detected.
es6format.js
String formatting that replicates the ES6 template operator but executes at runtime.
INSTALLATION
1 npm install es6format
USAGE
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!
DOCUMENTATION
Usage is straightforward:
1 format( <template-string>, ...args )
Arguments passed to the function are made available to the template via the following ways:
index ${0}
to reference arugments by order
1 format( "Hello, ${0}!", "World" );
strings ${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 );
'arg'+index ${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" );
expressions ${a + b}
1 format( "the sum of ${a} and ${b} is ${a + b}", {a: 2, b: 5} );
methods ${arg3.method()}
1 format( "Please don't ${arg0.toLowerCase()}", "YELL" );
args[index] ${args[3]}
to reference arugments programatically (e.g. ${args[arg0]})
1 format( "I am ${args[arg0]}", 1, "right", "wrong" )
${x=3}
${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 )
Arbitrary code ${ ...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 )
WARNING
es6format makes use of Function(), so it should never be called on format strings that are not known to be safe.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
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
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
3
/10
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