Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@rjweb/utils
Advanced tools
Easy and Lightweight Utilities
# NPM
npm install @rjweb/utils
# Yarn
yarn add @rjweb/utils
# pNPM
pnpm add @rjweb/utils
Generating a Random Number in Range
const { number } = require('@rjweb/utils')
const min = 50
const max = 100
const result = number.generate(min, max)
Generating a Random String
const { string } = require('@rjweb/utils')
const result = string.generate({
length: 25,
numbers: true,
symbols: true,
uppercase: true,
lowercase: true
})
Encrypting a String
const { string } = require('@rjweb/utils')
const result = string.encrypt('Hello', 'secret', {
output: 'hex'
})
Decrypting a String
const { string } = require('@rjweb/utils')
const result = string.decrypt('df4d0fe46e0210d4ef46368a6c3d56bb', 'secret', {
input: 'hex'
})
Hashing a String
const { string } = require('@rjweb/utils')
const result = string.hash('Hello', {
salt: 'secret',
algorithm: 'sha256',
output: 'hex'
})
Hashing a String using bcrypt
const { string } = require('@rjweb/utils')
const result = string.hashBCrypt('Hello', {
rounds: 5,
async: false
})
Comparing a Hashed String using bcrypt
const { string } = require('@rjweb/utils')
const result = string.compareBCrypt('Hello', '$2b$05$vi7.v6gPf6IIzumgUEbMyes8yZ0v8.8U0QaZZfXcldhrjiajBD2v2', {
async: false
})
Check if a Host is reachable
const { network } = require('@rjweb/utils')
// host, port, timeout ms
const result = await network.test('127.0.0.1', 80, 5000)
Parsing Options
const { object } = require('@rjweb/utils')
const original = {
ssl: true,
maxRequests: 10000,
other: {
clock: true,
date: {
enabled: true,
timezone: 'UTC'
}
}
}
const userProvided = {
ssl: false,
other: {
date: {
timezone: 'CET'
}
}
}
const result = object.deepParse(original, userProvided)
/**
* {
* ssl: false,
* maxRequests: 10000,
* other: {
* clock: true,
* date: {
* enabled: true,
* timezone: 'CET'
* }
* }
* }
*/
👤 0x7d8
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
Copyright © 2023 0x7d8.
This project is MIT licensed.
1.1.2
FAQs
Easy and Lightweight Utilities
The npm package @rjweb/utils receives a total of 5 weekly downloads. As such, @rjweb/utils popularity was classified as not popular.
We found that @rjweb/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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.