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.18.0 to 0.18.1

118

lib/format.js

@@ -579,56 +579,7 @@ /*

// natural (WIP)
modes.N = ( arg , isSubCall ) => {
if ( typeof arg === 'string' ) { return arg ; }
modes.N = ( arg , modeArg ) => genericNaturalMode( arg , modeArg , false ) ;
modes.n = ( arg , modeArg ) => genericNaturalMode( arg , modeArg , true ) ;
if ( arg === null || arg === undefined || arg === true || arg === false ) {
return '' + arg ;
}
if ( typeof arg === 'number' ) {
return modes.f( arg , '.3g ' ) ;
}
if ( Array.isArray( arg ) ) {
arg = arg.map( e => modes.N( e , true ) ) ;
if ( isSubCall ) {
return '[' + arg.join( ',' ) + ']' ;
}
return arg.join( ', ' ) ;
}
if ( Buffer.isBuffer( arg ) ) {
arg = [ ... arg ].map( e => {
e = e.toString( 16 ) ;
if ( e.length === 1 ) { e = '0' + e ; }
return e ;
} ) ;
return '<' + arg.join( ' ' ) + '>' ;
}
var proto = Object.getPrototypeOf( arg ) ;
if ( proto === null || proto === Object.prototype ) {
// Plain objects
arg = Object.entries( arg ).sort( naturalSort )
.map( e => e[ 0 ] + ': ' + modes.N( e[ 1 ] , true ) ) ;
if ( isSubCall ) {
return '{' + arg.join( ', ' ) + '}' ;
}
return arg.join( ', ' ) ;
}
if ( typeof arg.inspect === 'function' ) { return arg.inspect() ; }
if ( typeof arg.toString === 'function' ) { return arg.toString() ; }
return '(' + arg + ')' ;
} ;
modes.n = arg => modes.N( arg , true ) ;
// float

@@ -1175,2 +1126,67 @@ modes.f = ( arg , modeArg ) => {

// Generic Natural Mode
function genericNaturalMode( arg , modeArg , delimiters ) {
var depthLimit = 2 ;
if ( modeArg ) {
for ( let [ , k , v ] of modeArg.matchAll( MODE_ARG_FORMAT_REGEX ) ) {
if ( ! k ) {
depthLimit = parseInt( v , 10 ) || 1 ;
}
}
}
return genericNaturalModeRecursive( arg , delimiters , depthLimit , 0 ) ;
}
function genericNaturalModeRecursive( arg , delimiters , depthLimit , depth ) {
if ( typeof arg === 'string' ) { return arg ; }
if ( arg === null || arg === undefined || arg === true || arg === false ) {
return '' + arg ;
}
if ( typeof arg === 'number' ) {
return modes.f( arg , '.3g ' ) ;
}
if ( Array.isArray( arg ) ) {
if ( depth >= depthLimit ) { return '[...]' ; }
arg = arg.map( e => genericNaturalModeRecursive( e , true , depthLimit , depth + 1 ) ) ;
if ( delimiters ) { return '[' + arg.join( ',' ) + ']' ; }
return arg.join( ', ' ) ;
}
if ( Buffer.isBuffer( arg ) ) {
arg = [ ... arg ].map( e => {
e = e.toString( 16 ) ;
if ( e.length === 1 ) { e = '0' + e ; }
return e ;
} ) ;
return '<' + arg.join( ' ' ) + '>' ;
}
var proto = Object.getPrototypeOf( arg ) ;
if ( proto === null || proto === Object.prototype ) {
// Plain objects
if ( depth >= depthLimit ) { return '{...}' ; }
arg = Object.entries( arg ).sort( naturalSort )
.map( e => e[ 0 ] + ': ' + genericNaturalModeRecursive( e[ 1 ] , true , depthLimit , depth + 1 ) ) ;
if ( delimiters ) { return '{' + arg.join( ', ' ) + '}' ; }
return arg.join( ', ' ) ;
}
if ( typeof arg.inspect === 'function' ) { return arg.inspect() ; }
if ( typeof arg.toString === 'function' ) { return arg.toString() ; }
return '(' + arg + ')' ;
}
// Generic inspect

@@ -1177,0 +1193,0 @@ function genericInspectMode( arg , modeArg , options , modeOptions , isInspectError = false ) {

{
"name": "string-kit",
"version": "0.18.0",
"version": "0.18.1",
"engines": {

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

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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