Socket
Socket
Sign inDemoInstall

@rjweb/utils

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rjweb/utils

Easy and Lightweight Utilities


Version published
Weekly downloads
5
decreased by-79.17%
Maintainers
1
Weekly downloads
 
Created
Source

Welcome to @rjweb/utils 👋

Version Documentation Maintenance

Easy and Lightweight Utilities

🏠 Homepage

Install

# NPM
npm install @rjweb/utils

# Yarn
yarn add @rjweb/utils

# pNPM
pnpm add @rjweb/utils

Example Usage

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'
 *     }
 *   }
 * }
*/

Author

👤 0x7d8

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2023 0x7d8.
This project is MIT licensed.

Keywords

FAQs

Package last updated on 06 Sep 2023

Did you know?

Socket

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.

Install

Related posts

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