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

@waiting/shared-core

Package Overview
Dependencies
Maintainers
1
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waiting/shared-core - npm Package Compare versions

Comparing version 10.0.0 to 10.1.0

dist/lib/stats.d.ts

52

dist/index.cjs.js

@@ -5,3 +5,3 @@ /**

*
* @version 9.2.0
* @version 10.0.0
* @author waiting

@@ -287,2 +287,7 @@ * @license MIT

: path.normalize(process.env.HOME ? `${process.env.HOME}` : '');
const defaultPropDescriptor = {
configurable: true,
enumerable: true,
writable: true,
};

@@ -344,2 +349,29 @@ /**

}
const lookup = [
{ value: 1, symbol: '' },
{ value: 1e3, symbol: 'k' },
{ value: 1e6, symbol: 'M' },
{ value: 1e9, symbol: 'G' },
{ value: 1e12, symbol: 'T' },
{ value: 1e15, symbol: 'P' },
{ value: 1e18, symbol: 'E' },
];
/**
*
* @link https://stackoverflow.com/a/9462382
*/
function nFormatter(positiveNum, digits = 2, sep = '') {
if (positiveNum <= 0) {
return positiveNum.toString();
}
const item = lookup.slice().reverse().find((row) => {
return positiveNum >= row.value;
});
if (!item) {
return positiveNum.toString();
}
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/u;
const ret = (positiveNum / item.value).toFixed(digits).replace(rx, '$1') + sep + item.symbol;
return ret;
}

@@ -369,2 +401,17 @@ /**

/**
* Human-readable NodeJS.MemoryUsage
*/
function humanMemoryUsage(digits = 3, sep = ' ') {
const mu = process.memoryUsage();
const ret = {};
for (const [key, val] of Object.entries(mu)) {
Object.defineProperty(ret, key, {
...defaultPropDescriptor,
value: nFormatter(val, digits, sep),
});
}
return ret;
}
Object.defineProperty(exports, 'basename', {

@@ -423,2 +470,3 @@ enumerable: true,

exports.createFileAsync = createFileAsync;
exports.defaultPropDescriptor = defaultPropDescriptor;
exports.dirExists = dirExists;

@@ -428,2 +476,3 @@ exports.fileExists = fileExists;

exports.genRandomInt = genRandomInt;
exports.humanMemoryUsage = humanMemoryUsage;
exports.isDirExists = isDirExists;

@@ -435,2 +484,3 @@ exports.isDirFileExists = isDirFileExists;

exports.mkdirAsync = mkdirAsync;
exports.nFormatter = nFormatter;
exports.openAsync = openAsync;

@@ -437,0 +487,0 @@ exports.pathAccessible = pathAccessible;

export declare const isWin32: boolean;
export declare const userHome: string;
export declare const defaultPropDescriptor: PropertyDescriptor;

@@ -9,1 +9,6 @@ /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */

: normalize(process.env.HOME ? `${process.env.HOME}` : '');
export const defaultPropDescriptor = {
configurable: true,
enumerable: true,
writable: true,
};
/** Set loading path for node-ffi linking dll */
export declare function setPathDirectory(path: string): void;
/**
*
* @link https://stackoverflow.com/a/9462382
*/
export declare function nFormatter(positiveNum: number, digits?: number, sep?: string): string;

@@ -8,1 +8,28 @@ /** Set loading path for node-ffi linking dll */

}
const lookup = [
{ value: 1, symbol: '' },
{ value: 1e3, symbol: 'k' },
{ value: 1e6, symbol: 'M' },
{ value: 1e9, symbol: 'G' },
{ value: 1e12, symbol: 'T' },
{ value: 1e15, symbol: 'P' },
{ value: 1e18, symbol: 'E' },
];
/**
*
* @link https://stackoverflow.com/a/9462382
*/
export function nFormatter(positiveNum, digits = 2, sep = '') {
if (positiveNum <= 0) {
return positiveNum.toString();
}
const item = lookup.slice().reverse().find((row) => {
return positiveNum >= row.value;
});
if (!item) {
return positiveNum.toString();
}
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/u;
const ret = (positiveNum / item.value).toFixed(digits).replace(rx, '$1') + sep + item.symbol;
return ret;
}

@@ -8,1 +8,2 @@ export * from './asset';

export * from './string';
export * from './stats';

@@ -8,1 +8,2 @@ export * from './asset';

export * from './string';
export * from './stats';

6

package.json
{
"name": "@waiting/shared-core",
"author": "waiting",
"version": "10.0.0",
"version": "10.1.0",
"description": "node core function re export with Promise or Observable",

@@ -26,3 +26,3 @@ "keywords": [

"dependencies": {
"@waiting/shared-types": "^10.0.0",
"@waiting/shared-types": "^10.1.0",
"rxjs": "7"

@@ -95,3 +95,3 @@ },

},
"gitHead": "86cd39f655dad2f056627e50e83209a51283f077"
"gitHead": "cdd0e0fa621b31ffae5261e18fb7f268fae9add6"
}

@@ -13,1 +13,8 @@ /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */

export const defaultPropDescriptor: PropertyDescriptor = {
configurable: true,
enumerable: true,
writable: true,
} as const

@@ -10,1 +10,34 @@

interface Formater {
value: number
symbol: string
}
const lookup: Formater[] = [
{ value: 1, symbol: '' },
{ value: 1e3, symbol: 'k' },
{ value: 1e6, symbol: 'M' },
{ value: 1e9, symbol: 'G' },
{ value: 1e12, symbol: 'T' },
{ value: 1e15, symbol: 'P' },
{ value: 1e18, symbol: 'E' },
]
/**
*
* @link https://stackoverflow.com/a/9462382
*/
export function nFormatter(positiveNum: number, digits = 2, sep = ''): string {
if (positiveNum <= 0) {
return positiveNum.toString()
}
const item = lookup.slice().reverse().find((row) => {
return positiveNum >= row.value
})
if (! item) {
return positiveNum.toString()
}
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/u
const ret = (positiveNum / item.value).toFixed(digits).replace(rx, '$1') + sep + item.symbol
return ret
}

@@ -9,2 +9,3 @@

export * from './string'
export * from './stats'

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