Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@saulx/utils
Advanced tools
Saulx utils package, hashes are non cryptographic 32 bit hashes
Create a hash for any data type
import { hash } from '@saulx/utils'
console.log(hash({ x: true }))
import { hash } from '@saulx/utils'
// pads extra zeroes
console.log(hash({ x: true }, 15))
Create a hash for any data type, returns a base 62 string
import { hashCompact } from '@saulx/utils'
console.log(hashCompact({ x: true })) // -> CCoj0h
Passing an array and specifying more chars makes a hash that uses all avaible space to make it more unique (becomes more then 32 bits)
import { hashCompact } from '@saulx/utils'
console.log(hashCompact([{ x: true }, 'bla', 'blurp', 'snurf'], 20)) // -> CCoj0hNFgt8MovDmLkmh
Create a hash from objects or arrays
import { hashObject } from '@saulx/utils'
console.log(hashObject({ x: true }))
Only works for objects, creates the same hash independent from object key order
import { hashObject } from '@saulx/utils'
console.log(
hashObjectIgnoreKeyOrder({ x: true, y: true }) ===
hashObjectIgnoreKeyOrder({ y: true, x: true })
)
Creates a hash for strings
import { stringHash } from '@saulx/utils'
console.log(stringHash('bla bla bla'))
Compare objects
import { stringHash } from '@saulx/utils'
console.log(deepEqual({ a: { b: true } }, { a: { b: true } })) // true
Create a deepcopy of objects
import { deepCopy } from '@saulx/utils'
console.log(deepCopy({ x: true }))
Merge an object into another object, arrays are treated as new values
import { deepMerge } from '@saulx/utils'
const a = { x: { a: { c: true, x: [1, 2] } } }
const b = { y: true }
const c = { x: { a: { b: true, x: ['bla'] } } }
console.log(deepMerge(a, b))
console.log(deepMerge(a, b, c))
/*
Logs
{
x: { a: { b: true, c: true, x: ['bla']}},
y: true
}
*/
Merge an object into another object, arrays are treated as objects
import { deepMergeArrays } from '@saulx/utils'
const a = { x: { a: { c: true, x: [1, 2, 3] } } }
const b = { y: true }
const c = { x: { a: { b: true, x: ['bla'] } } }
console.log(deepMergeArrays(a, b))
console.log(deepMergeArrays(a, b, c))
/*
Logs
{
x: { a: { b: true, c: true, x: ['bla', 2, 3]}},
y: true
}
*/
Checks if a variable is an object and not an array
import { isObject } from '@saulx/utils'
console.log(isObject({ x: true })) // true
console.log(isObject([1, 2, 3])) // false
Timeout in a promise, default is 100ms
import { wait } from '@saulx/utils'
const somethingAsync = async () => {
await wait() // 100ms
console.log('after 100ms')
await wait(1000)
console.log('after 1100ms')
}
somethingAsync()
FAQs
Saulx utils package
The npm package @saulx/utils receives a total of 895 weekly downloads. As such, @saulx/utils popularity was classified as not popular.
We found that @saulx/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.