npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

superbuilt

v1.0.0

Published

100+ missing built-in functions for Node.js - range, shuffle, sprintf, ucfirst, chunk, sleep, and more!

Readme

SuperBuilt

100+ Missing Built-in Functions for Node.js

Stop writing boilerplate code! SuperBuilt adds the essential functions that should be built into JavaScript - range(), shuffle(), sprintf(), ucfirst(), sleep(), and 100+ more.

npm version License: MIT

Installation

npm install superbuilt

Quick Start

// Just require it once - functions are now globally available!
require('superbuilt');

// String functions
console.log(ucfirst('hello'));              // "Hello"
console.log(ucwords('hello world'));        // "Hello World"
console.log(sprintf('Hi %s!', 'John'));     // "Hi John!"

// Array functions
console.log(range(1, 6));                   // [1, 2, 3, 4, 5]
console.log([1, 2, 3, 4, 5].shuffle());     // [3, 1, 5, 2, 4]
console.log([1, 2, 3, 4, 5].sum());         // 15
console.log(chunk([1, 2, 3, 4, 5], 2));     // [[1, 2], [3, 4], [5]]

// Math functions
console.log(gcd(12, 18));                   // 6
console.log(factorial(5));                  // 120

// Validation
console.log(isEmail('[email protected]'));   // true
console.log(isEmpty(''));                   // true

// Utilities
await sleep(2);  // Sleep for 2 seconds
console.log(uuid());  // "a1b2c3d4-e5f6-..."

Usage Styles

Style 1: Global Registration (Recommended)

require('superbuilt');

// All functions available globally
console.log(range(5));
console.log('hello'.ucfirst());

Style 2: Module Import

const sb = require('superbuilt');

console.log(sb.range(5));
console.log(sb.ucfirst('hello'));

Style 3: Destructuring

const { range, shuffle, ucfirst } = require('superbuilt');

console.log(range(5));
console.log(shuffle([1, 2, 3]));

Style 4: Namespaced Access

const { str, arr, math, date, validate } = require('superbuilt');

console.log(str.ucfirst('hello'));
console.log(arr.shuffle([1, 2, 3]));
console.log(math.factorial(5));
console.log(date.format('Y-m-d'));
console.log(validate.isEmail('[email protected]'));

String Functions

| Function | Description | Example | |----------|-------------|---------| | ucfirst(str) | Capitalize first character | ucfirst('hello') → 'Hello' | | ucwords(str) | Capitalize each word | ucwords('hello world') → 'Hello World' | | lcfirst(str) | Lowercase first character | lcfirst('Hello') → 'hello' | | stripTags(str, allowed?) | Remove HTML tags | stripTags('<p>Hi</p>') → 'Hi' | | nl2br(str) | Newlines to <br> | nl2br('Hi\nThere') → 'Hi<br />There' | | htmlEntities(str) | Encode HTML entities | htmlEntities('<div>') → '&lt;div&gt;' | | htmlDecode(str) | Decode HTML entities | htmlDecode('&lt;div&gt;') → '<div>' | | sprintf(format, ...args) | Format string | sprintf('Hi %s, %d!', 'John', 25) | | numberFormat(num, dec?, decPoint?, thousandsSep?) | Format number | numberFormat(1234.5, 2) → '1,234.50' | | strPad(str, len, padStr?, type?) | Pad string | strPad('5', 3, '0', 'left') → '005' | | wordwrap(str, width?, breakStr?, cut?) | Wrap text | wordwrap('Long text...', 10) | | levenshtein(str1, str2) | Edit distance | levenshtein('hello', 'hallo') → 1 | | similarText(str1, str2) | Similarity (0-100) | similarText('hello', 'hallo') → 80 | | rot13(str) | ROT13 encoding | rot13('hello') → 'uryyb' | | truncate(str, len, suffix?) | Truncate with ellipsis | truncate('Hello World', 8) → 'Hello...' | | slugify(str) | Create URL slug | slugify('Hello World!') → 'hello-world' | | camelCase(str) | Convert to camelCase | camelCase('hello world') → 'helloWorld' | | snakeCase(str) | Convert to snake_case | snakeCase('helloWorld') → 'hello_world' | | kebabCase(str) | Convert to kebab-case | kebabCase('helloWorld') → 'hello-world' |

String Prototype Extensions

'hello world'.ucfirst()     // "Hello world"
'hello world'.ucwords()     // "Hello World"
'<p>text</p>'.stripTags()   // "text"
'Hello World'.slugify()     // "hello-world"
'long text here'.truncate(10)  // "long te..."

Array Functions

| Function | Description | Example | |----------|-------------|---------| | range(start?, end, step?) | Generate number sequence | range(1, 6) → [1, 2, 3, 4, 5] | | chunk(arr, size) | Split into chunks | chunk([1,2,3,4,5], 2) → [[1,2], [3,4], [5]] | | diff(arr1, ...arrs) | Array difference | diff([1,2,3], [2,3]) → [1] | | intersect(arr1, ...arrs) | Array intersection | intersect([1,2,3], [2,3,4]) → [2, 3] | | unique(arr) | Remove duplicates | unique([1,1,2,2,3]) → [1, 2, 3] | | uniqueBy(arr, key) | Unique by key | uniqueBy(users, 'id') | | sum(arr) | Sum of values | sum([1,2,3,4,5]) → 15 | | product(arr) | Product of values | product([1,2,3,4]) → 24 | | average(arr) | Average of values | average([1,2,3,4,5]) → 3 | | median(arr) | Median of values | median([1,2,3,4,5]) → 3 | | shuffle(arr) | Randomize order | shuffle([1,2,3,4,5]) → [3,1,5,2,4] | | random(arr, count?) | Random element(s) | random([1,2,3,4,5]) → 3 | | column(arr, key, indexKey?) | Extract column | column(users, 'name') | | combine(keys, values) | Create from keys/values | combine(['a','b'], [1,2]) → {a:1, b:2} | | flip(obj) | Swap keys/values | flip({a:1, b:2}) → {1:'a', 2:'b'} | | countValues(arr) | Count occurrences | countValues(['a','b','a']) → {a:2, b:1} | | groupBy(arr, key) | Group by key | groupBy(users, 'role') | | flatten(arr, depth?) | Flatten nested arrays | flatten([[1,2],[3,4]]) → [1,2,3,4] | | pluck(arr, key) | Extract values by key | pluck(users, 'name') → ['John', 'Jane'] | | partition(arr, fn) | Split by condition | partition([1,2,3,4], n => n > 2) | | zip(...arrays) | Zip arrays together | zip([1,2], ['a','b']) → [[1,'a'], [2,'b']] | | first(arr, count?) | Get first element(s) | first([1,2,3]) → 1 | | last(arr, count?) | Get last element(s) | last([1,2,3]) → 3 | | compact(arr) | Remove falsy values | compact([0,1,false,2]) → [1, 2] | | without(arr, ...vals) | Remove values | without([1,2,3], 2) → [1, 3] |

Array Prototype Extensions

[1, 2, 3, 4, 5].shuffle()      // [3, 1, 5, 2, 4]
[1, 2, 3, 4, 5].chunk(2)       // [[1, 2], [3, 4], [5]]
[1, 2, 3, 4, 5].sum()          // 15
[1, 2, 3, 4, 5].average()      // 3
[1, 1, 2, 2, 3].unique()       // [1, 2, 3]
[1, 2, 3].diff([2, 3, 4])      // [1]
[1, 2, 3].random()             // 2
[1, 2, 3].first()              // 1
[1, 2, 3].last()               // 3

Math Functions

| Function | Description | Example | |----------|-------------|---------| | gcd(a, b) | Greatest common divisor | gcd(12, 18) → 6 | | lcm(a, b) | Least common multiple | lcm(4, 6) → 12 | | factorial(n) | Factorial | factorial(5) → 120 | | fibonacci(n) | Fibonacci number | fibonacci(10) → 55 | | isPrime(n) | Check if prime | isPrime(17) → true | | deg2rad(deg) | Degrees to radians | deg2rad(180) → 3.14159... | | rad2deg(rad) | Radians to degrees | rad2deg(Math.PI) → 180 | | intdiv(a, b) | Integer division | intdiv(7, 3) → 2 | | fmod(a, b) | Float modulo | fmod(5.5, 2.5) → 0.5 | | baseConvert(num, from, to) | Base conversion | baseConvert('ff', 16, 10) → '255' | | clamp(val, min, max) | Clamp value | clamp(15, 0, 10) → 10 | | lerp(a, b, t) | Linear interpolation | lerp(0, 100, 0.5) → 50 | | roundTo(val, decimals?) | Round to decimals | roundTo(3.14159, 2) → 3.14 | | randInt(min, max) | Random integer | randInt(1, 10) → 7 | | randFloat(min, max) | Random float | randFloat(0, 1) → 0.5432... | | isEven(n) | Check if even | isEven(4) → true | | isOdd(n) | Check if odd | isOdd(3) → true |

Number Prototype Extensions

(5).times(i => i * 2)      // [0, 2, 4, 6, 8]
(4).isEven()               // true
(3).isOdd()                // true
(15).clamp(0, 10)          // 10
(3.14159).roundTo(2)       // 3.14

Date Functions

| Function | Description | Example | |----------|-------------|---------| | strtotime(str, now?) | Parse date string | strtotime('next monday') | | date(format, timestamp?) | Format date | date('Y-m-d H:i:s') → '2024-01-15 14:30:00' | | time() | Current Unix timestamp | time() → 1705326600 | | mktime(h, m, s, mon, day, year) | Create timestamp | mktime(12, 0, 0, 1, 15, 2024) | | checkdate(month, day, year) | Validate date | checkdate(2, 29, 2024) → true | | dateDiff(date1, date2) | Difference between dates | dateDiff(date1, date2).days | | dateAdd(timestamp, value, unit) | Add to date | dateAdd(time(), 7, 'days') | | relativeTime(timestamp) | Relative time string | relativeTime(past) → '2 hours ago' |

Date Format Characters

| Char | Description | Example | |------|-------------|---------| | Y | Full year | 2024 | | y | 2-digit year | 24 | | m | Month (01-12) | 01 | | n | Month (1-12) | 1 | | F | Full month name | January | | M | Short month name | Jan | | d | Day (01-31) | 15 | | j | Day (1-31) | 15 | | D | Short day name | Mon | | l | Full day name | Monday | | H | Hour 24h (00-23) | 14 | | h | Hour 12h (01-12) | 02 | | i | Minutes (00-59) | 30 | | s | Seconds (00-59) | 45 | | a | am/pm | pm | | A | AM/PM | PM |


Validation Functions

| Function | Description | Example | |----------|-------------|---------| | isNumeric(val) | Is numeric | isNumeric('123.45') → true | | isInt(val) | Is integer | isInt(42) → true | | isFloat(val) | Is float | isFloat(3.14) → true | | isString(val) | Is string | isString('hello') → true | | isArray(val) | Is array | isArray([1,2,3]) → true | | isObject(val) | Is object | isObject({a:1}) → true | | isNull(val) | Is null | isNull(null) → true | | isBool(val) | Is boolean | isBool(true) → true | | isCallable(val) | Is function | isCallable(() => {}) → true | | isEmpty(val) | Is empty | isEmpty('') → true | | ctypeAlpha(str) | Only letters | ctypeAlpha('Hello') → true | | ctypeDigit(str) | Only digits | ctypeDigit('12345') → true | | ctypeAlnum(str) | Letters & digits | ctypeAlnum('Hello123') → true | | isEmail(email) | Valid email | isEmail('[email protected]') → true | | isUrl(url) | Valid URL | isUrl('https://example.com') → true | | isIp(ip) | Valid IP address | isIp('192.168.1.1') → true | | isUuid(str) | Valid UUID | isUuid('a1b2c3d4-...') → true | | isJson(str) | Valid JSON | isJson('{"a":1}') → true | | isCreditCard(num) | Valid credit card | isCreditCard('4111111111111111') → true |


Utility Functions

| Function | Description | Example | |----------|-------------|---------| | sleep(seconds) | Pause execution | await sleep(2) | | delay(ms) | Delay in milliseconds | await delay(500) | | gettype(val) | Get type name | gettype([]) → 'array' | | varDump(...args) | Debug output | varDump(obj) | | clone(obj) | Deep clone | clone({a: {b: 1}}) | | merge(target, ...sources) | Deep merge | merge({a:1}, {b:2}) | | get(obj, path, default?) | Get nested value | get(obj, 'a.b.c', 0) | | set(obj, path, value) | Set nested value | set(obj, 'a.b.c', 42) | | has(obj, path) | Check path exists | has(obj, 'a.b.c') | | pick(obj, keys) | Pick keys | pick({a:1,b:2,c:3}, ['a','c']) | | omit(obj, keys) | Omit keys | omit({a:1,b:2,c:3}, ['b']) | | uuid() | Generate UUID v4 | uuid() → 'a1b2c3d4-...' | | randomString(len?, chars?) | Random string | randomString(16) | | debounce(fn, wait) | Debounce function | debounce(save, 300) | | throttle(fn, limit) | Throttle function | throttle(scroll, 100) | | memoize(fn) | Cache results | memoize(expensive) | | retry(fn, retries?, delay?) | Retry with backoff | await retry(fetch, 3) | | once(fn) | Run only once | once(initialize) | | compose(...fns) | Compose functions | compose(f, g, h) | | pipe(...fns) | Pipe functions | pipe(f, g, h) | | curry(fn) | Curry function | curry((a, b) => a + b) |


TypeScript Support

SuperBuilt includes full TypeScript definitions:

import 'superbuilt';

// All globals are typed
const result: string = ucfirst('hello');
const nums: number[] = range(1, 10);
const shuffled: number[] = [1, 2, 3].shuffle();

// Module import also typed
import sb from 'superbuilt';
const formatted: string = sb.sprintf('Hi %s', 'World');

Browser Support

SuperBuilt is designed for Node.js but can be bundled for browsers:

// Using webpack/rollup/etc
import 'superbuilt';

// All functions work in browser
console.log(range(1, 5));
console.log('hello'.ucfirst());

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - feel free to use in any project!


Made with love for the Node.js community