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

allowlist

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allowlist

Allow

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
441
increased by9.16%
Maintainers
1
Weekly downloads
 
Created
Source

Allowlist

Easy way to allow good values and deny bads

npm version npm downloads Github Actions Codecov

Install

Install using npm or yarn:

npm i allowlist
# or
yarn add allowlist

Import into your Node.js project:

// CommonJS
const allowlist = require('allowlist')

// ESM
import allowlist from 'allowlist'

Usage

Create a list:

// Allow a good string
const allow = allowlist('good')

// Allow a good string ignore case
const allow = allowlist('good', true)

// Allow a better regex
const allow = allowlist(/better/)

// Allow list of good values
const allow = allowlist([
    'good',
    /better/,
    /best/i
])

// Allow good values with your logic
const allow = allowlist((value) => {
    return value.includes('good')
})

// Deny bad values
const allow = allowlist({
    reject: [
        'bad',
        /awful/,
        /worse/i
    ]
})

// Allow good values and deny bads
const allow = allowlist({
    accept: [
        'good',
        /better/,
        /best/i
    ],
    reject: [
        'bad',
        /awful/,
        /worse/i
    ]
})

Check for good:

if (allow('Sometimes good things fall apart so better things can fall together.')) {
    // cool stuff
}

License

MIT. Made with 💖

FAQs

Package last updated on 30 Nov 2020

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