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

abcq

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abcq

Generates character combinations from numbers: `a b c ... aa ab ac ... foo fop foq`

  • 0.1.7
  • npm
  • Socket score

Version published
Weekly downloads
484
decreased by-30.56%
Maintainers
1
Weekly downloads
 
Created
Source

abcq

Generates character combinations from numbers: a b c ... aa ab ac ... foo fop foq

Documentation

npm GitHub license Travis David David GitHub issues GitHub forks GitHub stars js-standard-style Standard Version Commitizen friendly

  • Convert numbers to character combinations.
  • Count by character cobination
  • Create unique ids
  • Create simple hashes
npm i abcq

Basic usage

const shortid = new abcQ()

shortid.generate()
// -> a
shortid.generate()
// -> b
shortid.charsAt(1234567890)
// -> clRjXk

When unicorns make love

Use an Array for chars if it contains special characters. Set the counter to modify the start point

const unicornLove = new abcQ({
  chars: ['🦄','💖'],
  counter: 42
})

unicornLove.generate()
// -> 🦄💖💖🦄💖
unicornLove.charsAt(8)
// -> 🦄💖🦄

Use with cssmodules (+ browserify)

const browserify = require('browserify')
const cssModulesify = require('css-modulesify')
const abcQ = require('abcq')

function generator() {
  const shortid = new abcQ()
  this.names = {}
  return (name, file) => {
    const obj = this.names[file] || {}
    if (!(name in obj)) {
      obj[name] = shortid.generate()
    }
    this.names[file] = obj
    return obj[name]
  }
}

const entries = 'index.js'
const output = 'style.css'
const generateScopedName = new generator()

const b = browserify({entries})
b.plugin(cssModulesify, {output, generateScopedName})

Options

chars

  • type: { Array | String }
  • default: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

counter

  • type: { Number }
  • default: -1

Methods

generate

const abc = new abcQ()
abc.generate()
// -> a
abc.generate()
// -> b

charsAt

const abc = new abcQ()
abc.charsAt(1234567890)
// -> clRjXk

FAQs

Package last updated on 09 Sep 2016

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