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

string-kit

Package Overview
Dependencies
Maintainers
1
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-kit - npm Package Compare versions

Comparing version 0.12.4 to 0.12.5

74

documentation.md

@@ -64,31 +64,31 @@

* `%%` write a single %
* `%s` string
* `%S` string, interpret ^ formating
* `%r` raw string, without sanitizer
* `%n` natural: output the most natural representation for this type
* `%N` even more natural: avoid type hinting marks like bracket for array
* `%f` float number
* `%k` number to number with metric system prefixes (like k, M, G, and so on...)
* `%e` number to exponential “E notation”
* `%K` number to scientific notation
* `%i` integer
* `%d` alias of `%i` (*C*'s `printf` compatibility)
* `%u` unsigned integer
* `%U` unsigned positive integer (>0)
* `%P` number to (absolute) percent (e.g.: 0.75 -> 75%)
* `%p` number to relative percent (e.g.: 1.25 -> +25% ; 0.75 -> -25%)
* `%t` time duration, convert ms into H:min:s
* `%m` degrees/minutes/seconds notation
* `%h` unsigned hexadecimal
* `%x` unsigned hexadecimal, force pairs of symbols (e.g. 'f' -> '0f')
* `%o` unsigned octal
* `%b` unsigned binary
* `%s` to string, with sanitizer
* `%S` to string, with `^` interpretation
* `%r` to raw string, without any sanitizer
* `%n` to natural: output the most natural representation for this type
* `%N` to even more natural: avoid type hinting marks like bracket for array
* `%f` to (float) number
* `%k` to number with metric system prefixes (like k, M, G, and so on...)
* `%e` to exponential “E notation” (e.g. 13 -> 1.23e+2)
* `%K` to scientific notation (e.g. 123 -> 1.23 × 10²)
* `%i` to integer
* `%d` alias of `%i` (*C*'s `printf()` compatibility)
* `%u` to unsigned integer
* `%U` to unsigned positive integer (>0)
* `%P` to (absolute) percent (e.g.: 1.25 -> 125% ; 0.75 -> 75%)
* `%p` to relative percent (e.g.: 1.25 -> +25% ; 0.75 -> -25%)
* `%t` to time duration, convert ms into H:min:s
* `%m` to degrees/minutes/seconds notation
* `%h` to unsigned hexadecimal
* `%x` to unsigned hexadecimal, force pairs of symbols (e.g. 'f' -> '0f')
* `%o` to unsigned octal
* `%b` to unsigned binary
* `%X` string to hexadecimal: convert a string into hex charcode, force pair of symbols (e.g. 'f' -> '0f')
* `%z` base64
* `%Z` base64url
* `%O` object (call string-kit's inspect() with ultra-minimal options)
* `%z` to base64
* `%Z` to base64url
* `%O` for objects (call string-kit's inspect() with ultra-minimal options)
* `%I` call string-kit's inspect()
* `%Y` call string-kit's inspect(), but do not inspect non-enumerable
* `%E` call string-kit's inspectError()
* `%J` JSON.stringify()
* `%J` to JSON.stringify()
* `%D` drop, the argument does not produce anything but is eaten anyway

@@ -171,3 +171,3 @@ * `%F` filter function existing in the *this* context, e.g. %[filter:%a%a]F

A parameter consists in a letter, then exactly one character (letter or not letter), and eventually any number of non-letter characters.
A parameter consists in a letter, then one character (letter or not letter), that could be followed by any number of non-letter characters.
E.g. `%[L5]s`, the *L* parameter that produce left-padding to force a *5* characters-length.

@@ -183,3 +183,3 @@

Generic parameters -- they almost always exists for any specifier and use an upper-case parameter name :
Generic parameters -- they almost always exists for any specifier and use an upper-case parameter letter:
* L *integer*: it produces left-padding (using space) and force the length to the value

@@ -189,11 +189,13 @@ * R *integer*: same than *L* but produce right-padding instead

*Specifier's* specific parameters :
* %e:
* *integer*: the number of significative number for the scientific notation, e.g. `%[3]e`.
* %f:
* *integer*: the number precision in *digits*, e.g. `%[3]f`
* *integer* .: rounds to this integer place, e.g. `%[3.]f`
* . *integer*: rounds to this decimal place, e.g. `%[.3]f`
* . *integer* !: rounds to this decimal place and force displaying 0 up to this decimal place, e.g. `%[.3!]f`
* . *integer* ?: rounds to this decimal place and force displaying 0 up to this decimal place **if** there is at least one non-zero in the decimal part, e.g. `%[.3?]f`
* z *integer*: it produces zero padding for the integer part, e.g. `%[z3]f`
* %f %e %K %k %p %P:
* *integer*: the number precision in *digits*, e.g. `%[3]f` (12.345 -> 12.3)
* *integer* .: rounds to this integer place, e.g. `%[3.]f` (12345 -> 12000)
* . *integer*: rounds to this decimal place, e.g. `%[.2]f` (1.2345 -> 1.23)
* . *integer* !: rounds to this decimal place and force displaying 0 up to this decimal place,
e.g. `%[.2!]f` (12.9 -> 12.90 ; 12 -> 12.00) (useful for prices)
* . *integer* ?: rounds to this decimal place and force displaying 0 up to this decimal place **if** there is at least one non-zero in the decimal part,
e.g. `%[.2?]f` (12.9 -> 12.90 ; 12 -> 12)
* z *integer*: it produces zero padding for the integer part forcing at least *integer* digits, e.g. `%[z5]f` (12 -> 00012)
* g *char*: set a group separator character for thousands, e.g. `%[g,]f` (123456 -> 12,345)
* g: use the default group separator for thousands, e.g. `%[g]f` (123456 -> 12 345)
* %O %I %Y %E:

@@ -200,0 +202,0 @@ * *integer*: the depth of nested object inspection

@@ -292,6 +292,10 @@ /*

if ( arg === null || arg === undefined || arg === true || arg === false || typeof arg === 'number' ) {
if ( arg === null || arg === undefined || arg === true || arg === false ) {
return '' + arg ;
}
if ( typeof arg === 'number' ) {
return modes.f( arg , '.3g ' ) ;
}
if ( Array.isArray( arg ) ) {

@@ -298,0 +302,0 @@ arg = arg.map( e => modes.N( e , true ) ) ;

{
"name": "string-kit",
"version": "0.12.4",
"version": "0.12.5",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=6.0.0"

@@ -64,31 +64,31 @@

* `%%` write a single %
* `%s` string
* `%S` string, interpret ^ formating
* `%r` raw string, without sanitizer
* `%n` natural: output the most natural representation for this type
* `%N` even more natural: avoid type hinting marks like bracket for array
* `%f` float number
* `%k` number to number with metric system prefixes (like k, M, G, and so on...)
* `%e` number to exponential “E notation”
* `%K` number to scientific notation
* `%i` integer
* `%d` alias of `%i` (*C*'s `printf` compatibility)
* `%u` unsigned integer
* `%U` unsigned positive integer (>0)
* `%P` number to (absolute) percent (e.g.: 0.75 -> 75%)
* `%p` number to relative percent (e.g.: 1.25 -> +25% ; 0.75 -> -25%)
* `%t` time duration, convert ms into H:min:s
* `%m` degrees/minutes/seconds notation
* `%h` unsigned hexadecimal
* `%x` unsigned hexadecimal, force pairs of symbols (e.g. 'f' -> '0f')
* `%o` unsigned octal
* `%b` unsigned binary
* `%s` to string, with sanitizer
* `%S` to string, with `^` interpretation
* `%r` to raw string, without any sanitizer
* `%n` to natural: output the most natural representation for this type
* `%N` to even more natural: avoid type hinting marks like bracket for array
* `%f` to (float) number
* `%k` to number with metric system prefixes (like k, M, G, and so on...)
* `%e` to exponential “E notation” (e.g. 13 -> 1.23e+2)
* `%K` to scientific notation (e.g. 123 -> 1.23 × 10²)
* `%i` to integer
* `%d` alias of `%i` (*C*'s `printf()` compatibility)
* `%u` to unsigned integer
* `%U` to unsigned positive integer (>0)
* `%P` to (absolute) percent (e.g.: 1.25 -> 125% ; 0.75 -> 75%)
* `%p` to relative percent (e.g.: 1.25 -> +25% ; 0.75 -> -25%)
* `%t` to time duration, convert ms into H:min:s
* `%m` to degrees/minutes/seconds notation
* `%h` to unsigned hexadecimal
* `%x` to unsigned hexadecimal, force pairs of symbols (e.g. 'f' -> '0f')
* `%o` to unsigned octal
* `%b` to unsigned binary
* `%X` string to hexadecimal: convert a string into hex charcode, force pair of symbols (e.g. 'f' -> '0f')
* `%z` base64
* `%Z` base64url
* `%O` object (call string-kit's inspect() with ultra-minimal options)
* `%z` to base64
* `%Z` to base64url
* `%O` for objects (call string-kit's inspect() with ultra-minimal options)
* `%I` call string-kit's inspect()
* `%Y` call string-kit's inspect(), but do not inspect non-enumerable
* `%E` call string-kit's inspectError()
* `%J` JSON.stringify()
* `%J` to JSON.stringify()
* `%D` drop, the argument does not produce anything but is eaten anyway

@@ -171,3 +171,3 @@ * `%F` filter function existing in the *this* context, e.g. %[filter:%a%a]F

A parameter consists in a letter, then exactly one character (letter or not letter), and eventually any number of non-letter characters.
A parameter consists in a letter, then one character (letter or not letter), that could be followed by any number of non-letter characters.
E.g. `%[L5]s`, the *L* parameter that produce left-padding to force a *5* characters-length.

@@ -183,3 +183,3 @@

Generic parameters -- they almost always exists for any specifier and use an upper-case parameter name :
Generic parameters -- they almost always exists for any specifier and use an upper-case parameter letter:
* L *integer*: it produces left-padding (using space) and force the length to the value

@@ -189,11 +189,13 @@ * R *integer*: same than *L* but produce right-padding instead

*Specifier's* specific parameters :
* %e:
* *integer*: the number of significative number for the scientific notation, e.g. `%[3]e`.
* %f:
* *integer*: the number precision in *digits*, e.g. `%[3]f`
* *integer* .: rounds to this integer place, e.g. `%[3.]f`
* . *integer*: rounds to this decimal place, e.g. `%[.3]f`
* . *integer* !: rounds to this decimal place and force displaying 0 up to this decimal place, e.g. `%[.3!]f`
* . *integer* ?: rounds to this decimal place and force displaying 0 up to this decimal place **if** there is at least one non-zero in the decimal part, e.g. `%[.3?]f`
* z *integer*: it produces zero padding for the integer part, e.g. `%[z3]f`
* %f %e %K %k %p %P:
* *integer*: the number precision in *digits*, e.g. `%[3]f` (12.345 -> 12.3)
* *integer* .: rounds to this integer place, e.g. `%[3.]f` (12345 -> 12000)
* . *integer*: rounds to this decimal place, e.g. `%[.2]f` (1.2345 -> 1.23)
* . *integer* !: rounds to this decimal place and force displaying 0 up to this decimal place,
e.g. `%[.2!]f` (12.9 -> 12.90 ; 12 -> 12.00) (useful for prices)
* . *integer* ?: rounds to this decimal place and force displaying 0 up to this decimal place **if** there is at least one non-zero in the decimal part,
e.g. `%[.2?]f` (12.9 -> 12.90 ; 12 -> 12)
* z *integer*: it produces zero padding for the integer part forcing at least *integer* digits, e.g. `%[z5]f` (12 -> 00012)
* g *char*: set a group separator character for thousands, e.g. `%[g,]f` (123456 -> 12,345)
* g: use the default group separator for thousands, e.g. `%[g]f` (123456 -> 12 345)
* %O %I %Y %E:

@@ -200,0 +202,0 @@ * *integer*: the depth of nested object inspection

@@ -393,6 +393,25 @@ /*

it( "%n natural" ) ;
it( "%N more natural" ) ;
it( "%N and object keys sorting" , () => {
it( "%n natural" , () => {
expect( format( '%n' , 12345 ) ).to.be( '12 345' ) ;
expect( format( '%n' , 1.23456789 ) ).to.be( '1.235' ) ;
expect( format( '%n' , true ) ).to.be( 'true' ) ;
expect( format( '%n' , false ) ).to.be( 'false' ) ;
expect( format( '%n' , null ) ).to.be( 'null' ) ;
expect( format( '%n' , [ 'one' , 'two' , 'three' ] ) ).to.be( '[one,two,three]' ) ;
// Object and key sorting
expect( format( '%n' , { bob: 3 , alice: 4 , john: 2 , jack: 3 } ) ).to.be( '{alice: 4, bob: 3, jack: 3, john: 2}' ) ;
} ) ;
it( "%N more natural" , () => {
expect( format( '%N' , 12345 ) ).to.be( '12 345' ) ;
expect( format( '%N' , 1.23456789 ) ).to.be( '1.235' ) ;
expect( format( '%N' , true ) ).to.be( 'true' ) ;
expect( format( '%N' , false ) ).to.be( 'false' ) ;
expect( format( '%N' , null ) ).to.be( 'null' ) ;
expect( format( '%N' , [ 'one' , 'two' , 'three' ] ) ).to.be( 'one, two, three' ) ;
// Object and key sorting
expect( format( '%N' , { bob: 3 , alice: 4 , john: 2 , jack: 3 } ) ).to.be( 'alice: 4, bob: 3, jack: 3, john: 2' ) ;

@@ -399,0 +418,0 @@ } ) ;

Sorry, the diff of this file is not supported yet

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