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

@saulx/utils

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saulx/utils - npm Package Compare versions

Comparing version 2.4.1 to 3.0.0

dist/base64.d.ts

1

dist/deepMerge.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deepMerge = exports.deepMergeArrays = void 0;
const merge = (target, source) => {

@@ -5,0 +4,0 @@ if (source.constructor === Array) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getType = void 0;
exports.getType = (item) => {

@@ -5,0 +4,0 @@ return item === null ? 'null' : Array.isArray(item) ? 'array' : typeof item;

@@ -8,9 +8,10 @@ import deepCopy from './deepCopy';

import queued from './queued';
import obscurify from './obscurify';
import retry from './retry';
import randomString from './randomString';
export { deepCopy, queued, readStream, isObject, wait, deepEqual, toEnvVar, retry, randomString, };
export * from './deepMerge';
export { deepCopy, queued, obscurify, readStream, isObject, wait, deepEqual, toEnvVar, retry, randomString, };
export * from './walker';
export * from './getType';
export * from './parseQuery';
export * from './query';
export * from './base64';
export * from './utf8';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -16,3 +9,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.randomString = exports.retry = exports.toEnvVar = exports.deepEqual = exports.wait = exports.isObject = exports.readStream = exports.obscurify = exports.queued = exports.deepCopy = void 0;
const deepCopy_1 = __importDefault(require("./deepCopy"));

@@ -32,4 +24,2 @@ exports.deepCopy = deepCopy_1.default;

exports.queued = queued_1.default;
const obscurify_1 = __importDefault(require("./obscurify"));
exports.obscurify = obscurify_1.default;
const retry_1 = __importDefault(require("./retry"));

@@ -39,6 +29,8 @@ exports.retry = retry_1.default;

exports.randomString = randomString_1.default;
__exportStar(require("./deepMerge"), exports);
__exportStar(require("./walker"), exports);
__exportStar(require("./getType"), exports);
__exportStar(require("./parseQuery"), exports);
__export(require("./deepMerge"));
__export(require("./walker"));
__export(require("./getType"));
__export(require("./query"));
__export(require("./base64"));
__export(require("./utf8"));
//# sourceMappingURL=index.js.map

@@ -0,1 +1,41 @@

declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b: B, c: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c: C, d: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b: B, c: C, d: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b: B, c: C, d: D, e: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b: B, c: C, d: D, e: E, f: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h?: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i?: I, j?: J) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j?: J) => Promise<K>;
declare function queued<K>(promiseFn: () => Promise<K>, opts?: {

@@ -5,46 +45,42 @@ concurrency?: number;

}): () => Promise<K>;
declare function queued<A, K>(promiseFn: (a?: A) => Promise<K>, opts?: {
declare function queued<A, K>(promiseFn: (a: A) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A) => Promise<K>;
declare function queued<A, B, K>(promiseFn: (a?: A, b?: B) => Promise<K>, opts?: {
}): (a: A) => Promise<K>;
declare function queued<A, B, K>(promiseFn: (a: A, b: B) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B) => Promise<K>;
declare function queued<A, B, C, K>(promiseFn: (a?: A, b?: B, c?: C) => Promise<K>, opts?: {
}): (a: A, b: B) => Promise<K>;
declare function queued<A, B, C, K>(promiseFn: (a: A, b: B, c: C) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C) => Promise<K>;
declare function queued<A, B, C, D, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D) => Promise<K>, opts?: {
}): (a: A, b: B, c: C) => Promise<K>;
declare function queued<A, B, C, D, K>(promiseFn: (a: A, b: B, c: C, d: D) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D) => Promise<K>;
declare function queued<A, B, C, D, E, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E) => Promise<K>, opts?: {
}): (a: A, b: B, c: C, d: D) => Promise<K>;
declare function queued<A, B, C, D, E, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D, e?: E) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E) => Promise<K>, opts?: {
}): (a: A, b: B, c: C, d: D, e: E) => Promise<K>;
declare function queued<A, B, C, D, E, F, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G) => Promise<K>;
declare function queued<A, B, C, D, E, F, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F) => Promise<K>, opts?: {
}): (a: A, b: B, c: C, d: D, e: E, f: F) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G) => Promise<K>, opts?: {
}): (a: A, b: B, c: C, d: D, e: E, f: F, g: G) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H) => Promise<K>, opts?: {
}): (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I) => Promise<K>, opts?: {
}): (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I) => Promise<K>;
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: {
concurrency?: number;
dedup?: (...args: any[]) => number | string;
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>;
}): (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J) => Promise<K>;
export default queued;

@@ -10,6 +10,7 @@ "use strict";

function randomString(length, opts) {
const noSpecials = (opts === null || opts === void 0 ? void 0 : opts.noSpecials) || false;
const noLowerCase = (opts === null || opts === void 0 ? void 0 : opts.noLowerCase) || false;
const noUpperCase = (opts === null || opts === void 0 ? void 0 : opts.noUpperCase) || false;
const noNumbers = (opts === null || opts === void 0 ? void 0 : opts.noNumbers) || false;
var _a, _b, _c, _d;
const noSpecials = ((_a = opts) === null || _a === void 0 ? void 0 : _a.noSpecials) || false;
const noLowerCase = ((_b = opts) === null || _b === void 0 ? void 0 : _b.noLowerCase) || false;
const noUpperCase = ((_c = opts) === null || _c === void 0 ? void 0 : _c.noUpperCase) || false;
const noNumbers = ((_d = opts) === null || _d === void 0 ? void 0 : _d.noNumbers) || false;
const upperCaseChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

@@ -16,0 +17,0 @@ const lowerCaseChars = 'abcdefghijklmnopqrstuvwxyz';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.walk = void 0;
const _1 = require("./");

@@ -5,0 +4,0 @@ const defaultItemMatchFn = async (item) => _1.getType(item.ref) !== 'object';

{
"name": "@saulx/utils",
"main": "./dist/index.js",
"version": "2.4.1",
"version": "3.0.0",
"scripts": {

@@ -23,6 +23,4 @@ "build": "tsc",

"files": [
"test/**/*.ts",
"!test/examples"
"test/**/*.ts"
],
"compileEnhancements": false,
"extensions": [

@@ -49,3 +47,3 @@ "ts"

"@saulx/prettier-config": "https://github.com/atelier-saulx/prettier-config",
"ava": "2.4.0",
"ava": "3.15.0",
"eslint": "^7.18.0",

@@ -55,5 +53,5 @@ "husky": "^3.0.8",

"prettier": "^2.2.1",
"ts-node": "^8.5.4",
"typescript": "^3.7.3"
"ts-node": "8.5.4",
"typescript": "3.7.3"
}
}

@@ -88,6 +88,6 @@ # utils

const somethingAsync = async () => {
await wait() // 100ms
console.log('after 100ms')
await wait(1000)
console.log('after 1100ms')
await wait() // 100ms
console.log('after 100ms')
await wait(1000)
console.log('after 1100ms')
}

@@ -98,2 +98,23 @@

## serializeQuery
Convert an object to a query string
```javascript
import { serializeQuery } from '@saulx/utils'
const object = { bla: true, a: [1, 2, 3], b: { a: 1 }, c: ['a', 'b', 'c'] }
const queryString = serializeQuery(object)
console.log(queryString) // bla&a=[1,2,3]&b={"a":1}&c=a,b,c
```
## parseQuery
Convert a query string to an object
```javascript
import { parseQuery } from '@saulx/utils'
const result = parseQuery('bla&a=[1,2,3]&b={"a":1}&c=a,b,c')
console.log(result) // { bla:true, a:[1,2,3], b:{a:1}, c:['a','b','c'] }
```
## readStream

@@ -113,3 +134,3 @@

Convert a string to a env variable safe name
Convert a string to an env-variable safe name

@@ -122,2 +143,48 @@ ```javascript

## stringToUtf8
Convert a string to a utf-8 Uint8 array
```javascript
import { stringToUtf8 } from '@saulx/utils'
const utf8 = stringToUtf8('hello')
console.log(utf8) // [ 104, 101, 108, 108, 111 ]
```
## uft8ToString
Convert a utf8 Uint8 array to a string
```javascript
import { utf8ToString } from '@saulx/utils'
// hello in utf-8
const utf8 = new Uint8Array([104, 101, 108, 108, 111])
const x = utf8ToString(utf8)
console.log(x) // hello
```
## encodeBase64
Convert utf-8 Uint8 array to a base64 string, allows converting 16byte chars.
(vs btoa where its not supported)
```javascript
import { encodeBase64 } from '@saulx/utils'
// hello in utf-8
const utf8 = new Uint8Array([104, 101, 108, 108, 111])
const b64 = encodeBase64(utf8)
console.log(b64) // aGVsbG8=
```
## decodeBase64
Decoded a base64 string to a utf-8 Uint8 array
(vs atob where its not supported)
```javascript
import { decodeBase64 } from '@saulx/utils'
const utf8 = decodeBase64('aGVsbG8=)
console.log(b64) // [104, 101, 108, 108, 111]
```
## queued

@@ -127,3 +194,3 @@

Accepts 5 arguments maximum!
_Accepts 10 arguments maximum_

@@ -168,23 +235,22 @@ ```javascript

```
## getType
Returns a string with the operand/type of the javascrit primitive. Adds 'null' and 'array'.
Returns a string with the operand/type of the javascrit primitive. Adds 'null' and 'array'.
```javascript
getType('') // -> "string"
getType('this is a string') // -> "string"
getType(123) // -> "number"
getType(12.3) // -> "number"
getType(-12.3) // -> "number"
getType(-123) // -> "number"
getType(BigInt('1')) // -> "bigint"
getType(true) // -> "boolean"
getType(false) // -> "boolean"
getType(undefined) // -> "undefined"
getType({}) // -> "object"
getType({ a: 'wawa' }) // -> "object"
getType(() => {}) // -> "function"
getType([]) // -> "array"
getType([1, 2, 3]) // -> "array"
getType(null) // -> "null"
getType('') // -> "string"
getType('this is a string') // -> "string"
getType(123) // -> "number"
getType(12.3) // -> "number"
getType(-12.3) // -> "number"
getType(-123) // -> "number"
getType(BigInt('1')) // -> "bigint"
getType(true) // -> "boolean"
getType(false) // -> "boolean"
getType(undefined) // -> "undefined"
getType({ a: 'wawa' }) // -> "object"
getType(() => {}) // -> "function"
getType([1, 2, 3]) // -> "array"
getType(null) // -> "null"
```

@@ -197,11 +263,11 @@

```javascript
const result = []
await walk(objectToWalk, async (item, info) => {
result.push({
value: item,
name: info.name, // property name
path: info.path, // slash separated path in object
type: info.type // operand type
})
}) // returns void
const result = []
await walk(objectToWalk, async (item, info) => {
result.push({
value: item,
name: info.name, // property name
path: info.path, // slash separated path in object
type: info.type, // operand type
})
}) // returns void
```

@@ -223,3 +289,3 @@

}
})
)
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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