All Projects β†’ anatol-grabowski β†’ incstr

anatol-grabowski / incstr

Licence: MIT license
Increment string or generate sequential string ids

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to incstr

calculate-aspect-ratio
πŸ“ A simple utility function, and command line utility, for calculating an aspect ratio based on width and height.
Stars: ✭ 43 (-41.1%)
Mutual labels:  npm-module
easyvk
This app helps you create an apps with vk api easy!
Stars: ✭ 97 (+32.88%)
Mutual labels:  npm-module
windows-network-drive
Do network drive stuff on Microsoft Window in node
Stars: ✭ 18 (-75.34%)
Mutual labels:  npm-module
js-stack-from-scratch
🌺 Russian translation of "JavaScript Stack from Scratch" from the React-Theming developers https://github.com/sm-react/react-theming
Stars: ✭ 394 (+439.73%)
Mutual labels:  npm-module
micro-signals
A tiny typed messaging system inspired by js-signals that uses ES2015 sets
Stars: ✭ 39 (-46.58%)
Mutual labels:  npm-module
yamlinc
Compose multiple YAML files into one with $include tag. Split Swagger/OpenAPI into multiple YAML files.
Stars: ✭ 103 (+41.1%)
Mutual labels:  npm-module
extension-generator
This package is no longer supported. Please use https://github.com/flarum/cli instead.
Stars: ✭ 53 (-27.4%)
Mutual labels:  npm-module
pokemon-random
API & NPM Module To Express Random Pokemon
Stars: ✭ 47 (-35.62%)
Mutual labels:  npm-module
surger
⚑ Is there surge pricing around me right now?
Stars: ✭ 20 (-72.6%)
Mutual labels:  npm-module
React-Pincode
A NPM module which auto fills City, District and State fields when a valid Zip Code in entered!
Stars: ✭ 26 (-64.38%)
Mutual labels:  npm-module
intersection-wasm
Mesh-Mesh and Triangle-Triangle Intersection tests based on the algorithm by Tomas Akenine-MΓΆller
Stars: ✭ 17 (-76.71%)
Mutual labels:  npm-module
MinifyAllCli
πŸ“¦ A lightweight, simple and easy npm tool to π—Ίπ—Άπ—»π—Άπ—³π˜† JSON/C, HTML and CSS! Also known as MinifyAll core! ⭐ Usable as π‘ͺ𝑳𝑰 tool or π’Šπ’Žπ’‘π’π’“π’•π’‚π’ƒπ’π’† in TS/JS as a 𝑴𝑢𝑫𝑼𝑳𝑬 πŸ₯°
Stars: ✭ 21 (-71.23%)
Mutual labels:  npm-module
react-folder-tree
A versatile react treeview library that supports custom icons and event handlers
Stars: ✭ 56 (-23.29%)
Mutual labels:  npm-module
bettertext.css
Improved default typography for naked HTML or Markdown-generated content.
Stars: ✭ 36 (-50.68%)
Mutual labels:  npm-module
react-native-input-prompt
A cross-platform user input prompt component for React Native with Native UI.
Stars: ✭ 45 (-38.36%)
Mutual labels:  npm-module
json-as-xlsx
Create excel from json npm package
Stars: ✭ 103 (+41.1%)
Mutual labels:  npm-module
ts-ci
πŸš€ A starter for TS projects meant to be published on NPM.
Stars: ✭ 282 (+286.3%)
Mutual labels:  npm-module
heic-convert
🀳 convert heic/heif images to jpeg and png
Stars: ✭ 104 (+42.47%)
Mutual labels:  npm-module
stalin-sort
A repressive sorting algorithm (not really sorting)
Stars: ✭ 13 (-82.19%)
Mutual labels:  npm-module
protocol-registry
This module allows you to set custom protocol handler for your nodejs app.
Stars: ✭ 45 (-38.36%)
Mutual labels:  npm-module

incstr

Increment strings or generate sequential string ids in node.js or browser

Usage

incstr

const incstr = require('incstr')
nextStr = incstr(str,
                 [alphabet=incstr.alphabet],
                 [numberlike=incstr.numberlike])
  • str - string to increment;
  • alphabet - alphabet to use (default 'A..Za..z0..9');
  • numberlike - 'BA' after '9' instead of 'AA'(default false);
  • default alphabet can be set through incstr.alphabet;
  • default value for numberlike can be set through incstr.numberlike;
  • works with strings of any length.

incstr.idGenerator

nextId = incstr.idGenerator(options)
id = nextId() // real generator would be too bulky "nextId.next().value"

Possible options:

  • options.lastId;
  • options.alphabet;
  • options.numberlike;
  • options.prefix;
  • options.suffix.

lastId can also be accessed later through nextId.lastId property. Note that idGenerator is more than twice as fast as incstr.

Examples

Pass a string to increment using default alphabet:

let i = incstr() // "A"
i = incstr(i) // "B"
...
i = incstr(i) // "9"
i = incstr(i) // "AA"
i = incstr(i) // "AB"

Pass a string and an alphabet to use:

incstr("ccc", "abc") // "aaaa"
incstr("cc", "ab") // throws ('c' is not in alphabet 'ab')
incstr("0", "01") // "1"
incstr("1", "01") // "00", note NOT "10"
incstr("1", "01", true) // "10", numberlike increment

Generate ids:

const nextId = incstr.idGenerator()
id1 = nextId() // 'A'
id2 = nextId() // 'B'
const nextId = incstr.idGenerator({alphabet:'ab', prefix:'id_', suffix:''})
nextId() // 'id_a'
nextId() // 'id_b'
nextId() // 'id_aa'
const nextId = incstr.idGenerator({lastId:'cc', alphabet:'abc', numberlike: true})
id = nextId() // 'baa'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].