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

easyjs-empty

v0.1.1

Published

An empty core of @cooljs123/easyjs for plugins (e.g., easyjs-maths, easyjs-time, easyjs-random).

Readme

EasyJS Empty

Minimal EasyJS core with only a plugin system. Nothing is loaded by default.

Install

npm i easyjs-empty

Plugins

A plugin is a function that receives the EasyJS instance and adds methods.

const reversePlugin = (easy) => {
  easy.reverse = (str) => String(str).split("").reverse().join("");
};

easy.use(reversePlugin);
console.log(easy.reverse("hello")); // "olleh"

Official Plugins (Examples)

Install

npm i easyjs-maths easyjs-time easyjs-random easyjs-date easyjs-json easyjs-collections

Each plugin has:

  • basic set loaded by easy.use(plugin)
  • advanced set loaded by easy.use(plugin.advanced)

easyjs-maths

easy.use(maths) loads basic. easy.use(maths.advanced) loads basic + advanced + random.

Basic

sqrt

// Takes a number and returns square root.
easy.sqrt(9) // 3

pow

// Takes base and exponent and returns power.
easy.pow(2, 3) // 8

floor

// Takes a number and returns floor.
easy.floor(3.9) // 3

ceil

// Takes a number and returns ceil.
easy.ceil(3.1) // 4

round

// Takes a number and returns rounded.
easy.round(3.5) // 4

abs

// Takes a number and returns absolute value.
easy.abs(-5) // 5

min

// Takes numbers and returns smallest.
easy.min(3, 1, 9) // 1

max

// Takes numbers and returns largest.
easy.max(3, 1, 9) // 9

Advanced

factorial

// Takes a non-negative integer and returns factorial.
easy.factorial(5) // 120

gcd

// Takes two integers and returns greatest common divisor.
easy.gcd(12, 18) // 6

lcm

// Takes two integers and returns least common multiple.
easy.lcm(4, 6) // 12

lerp

// Takes a, b, t and returns linear interpolation.
easy.lerp(0, 10, 0.5) // 5

sin

// Takes radians and returns sine.
easy.sin(Math.PI / 2) // 1

cos

// Takes radians and returns cosine.
easy.cos(0) // 1

tan

// Takes radians and returns tangent.
easy.tan(0) // 0

asin

// Takes value and returns arcsin (radians).
easy.asin(1) // 1.5707963267948966

acos

// Takes value and returns arccos (radians).
easy.acos(1) // 0

atan

// Takes value and returns arctan (radians).
easy.atan(1) // 0.7853981633974483

log

// Takes value (and optional base) and returns log.
easy.log(8, 2) // 3

log10

// Takes value and returns base-10 log.
easy.log10(100) // 2

pi

// Constant pi.
easy.pi // 3.141592653589793

e

// Constant e.
easy.e // 2.718281828459045

Random (also in advanced)

random

// Returns random float 0..1.
easy.random() // random

randint

// Takes min/max and returns random integer.
easy.randint(1, 6) // 1..6

choice

// Takes array and returns random element.
easy.choice(["a", "b"]) // "a" or "b"

shuffle

// Takes array and returns shuffled copy.
easy.shuffle([1,2,3]) // random order

uniform

// Takes min/max and returns random float.
easy.uniform(1, 2) // 1..2

sample

// Takes array and n, returns n random elements.
easy.sample([1,2,3,4], 2) // random 2

easyjs-time

easy.use(time) loads basic. easy.use(time.advanced) loads basic + advanced.

Basic

now

// Returns current Date.
easy.now() // Date

time

// Returns seconds since epoch.
easy.time() // number

sleep

// Takes seconds and returns a Promise that resolves after delay.
await easy.sleep(1) // Promise

ctime

// Takes seconds (optional) and returns Date string.
easy.ctime(0) // "Thu Jan 01 1970 ..."

localtime

// Takes seconds (optional) and returns Date.
easy.localtime(0) // Date

gmtime

// Takes seconds (optional) and returns Date.
easy.gmtime(0) // Date

Advanced

timeMs

// Returns milliseconds since epoch.
easy.timeMs() // number

timeNs

// Returns nanoseconds (best effort).
easy.timeNs() // bigint or number

monotonic

// Returns monotonic clock in ms.
easy.monotonic() // number

perfCounter

// Returns high-resolution timer in ms.
easy.perfCounter() // number

perfCounterNs

// Returns high-resolution timer in ns (best effort).
easy.perfCounterNs() // bigint or number

sleepMs

// Takes ms and returns Promise after delay.
await easy.sleepMs(50) // Promise

timer

// Returns a function that gives elapsed ms.
const t = easy.timer();
t(); // number

elapsed

// Takes start ms and returns elapsed.
easy.elapsed(Date.now() - 1000) // ~1000

format

// Formats a Date with pattern.
easy.format(new Date(0), "YYYY-MM-DD") // "1970-01-01"

strftime

// Formats a Date with % tokens.
easy.strftime("%Y-%m-%d", new Date(0)) // "1970-01-01"

timezoneOffsetMinutes

// Returns local timezone offset in minutes.
easy.timezoneOffsetMinutes() // number

easyjs-random

easy.use(random) loads basic. easy.use(random.advanced) loads basic + advanced.

Basic

random

// Returns random float 0..1.
easy.random() // random

randint

// Takes min/max and returns random integer.
easy.randint(1, 6) // 1..6

choice

// Takes array and returns random element.
easy.choice(["a", "b"]) // "a" or "b"

shuffle

// Takes array and returns shuffled copy.
easy.shuffle([1,2,3]) // random order

Advanced

uniform

// Takes min/max and returns random float.
easy.uniform(1, 2) // 1..2

sample

// Takes array and n, returns n random elements.
easy.sample([1,2,3,4], 2) // random 2

chance

// Takes probability 0..1 and returns true/false.
easy.chance(0.25) // true/false

weightedChoice

// Takes items and weights and returns one item.
easy.weightedChoice(["a","b"],[1,3]) // "b" more often

easyjs-date

easy.use(date) loads basic. easy.use(date.advanced) loads basic + advanced.

Basic

today

// Returns current Date.
easy.today() // Date

date

// Returns current Date.
easy.date() // Date

year

// Takes Date and returns year.
easy.year(new Date(0)) // 1970

month

// Takes Date and returns month (1-12).
easy.month(new Date(0)) // 1

day

// Takes Date and returns day of month.
easy.day(new Date(0)) // 1

weekday

// Takes Date and returns day of week (0-6).
easy.weekday(new Date(0)) // 4

toISO

// Takes Date and returns ISO string.
easy.toISO(new Date(0)) // "1970-01-01T00:00:00.000Z"

parseDate

// Takes input and returns Date.
easy.parseDate("2020-01-01") // Date

Advanced

addDays

// Takes Date and number of days, returns new Date.
easy.addDays("2020-01-01", 1) // Date

addMonths

// Takes Date and number of months, returns new Date.
easy.addMonths("2020-01-01", 1) // Date

addYears

// Takes Date and number of years, returns new Date.
easy.addYears("2020-01-01", 1) // Date

startOfDay

// Takes Date and returns start of day.
easy.startOfDay("2020-01-01") // Date

endOfDay

// Takes Date and returns end of day.
easy.endOfDay("2020-01-01") // Date

diffDays

// Takes two dates and returns day difference.
easy.diffDays("2020-01-01", "2020-01-05") // 4

isLeapYear

// Takes year and returns true if leap year.
easy.isLeapYear(2024) // true

formatDate

// Formats a Date with pattern.
easy.formatDate(new Date(0), "YYYY-MM-DD") // "1970-01-01"

easyjs-json

easy.use(json) loads basic. easy.use(json.advanced) loads basic + advanced.

Basic

parse

// Takes JSON string and returns object.
easy.parse('{"a":1}') // { a: 1 }

stringify

// Takes value and returns JSON string.
easy.stringify({ a: 1 }) // "{\"a\":1}"

clone

// Takes JSON-serializable value and deep clones.
easy.clone({ a: 1 }) // { a: 1 }

Advanced

safeParse

// Takes JSON string and fallback, returns object or fallback.
easy.safeParse("{bad}", null) // null

safeStringify

// Takes value and returns JSON string or null.
easy.safeStringify({ a: 1 }) // "{\"a\":1}"

pretty

// Takes value and returns pretty JSON string.
easy.pretty({ a: 1 }) // "{\n  \"a\": 1\n}"

compact

// Takes value and returns compact JSON string.
easy.compact({ a: 1 }) // "{\"a\":1}"

isValid

// Takes JSON string and returns true/false.
easy.isValid('{"a":1}') // true

easyjs-collections

easy.use(collections) loads basic. easy.use(collections.advanced) loads basic + advanced.

Basic

size

// Takes collection and returns size.
easy.size([1,2,3]) // 3

keys

// Takes object and returns keys.
easy.keys({ a: 1 }) // ["a"]

values

// Takes object and returns values.
easy.values({ a: 1 }) // [1]

entries

// Takes object and returns entries.
easy.entries({ a: 1 }) // [["a", 1]]

first

// Takes array and returns first.
easy.first([1,2,3]) // 1

last

// Takes array and returns last.
easy.last([1,2,3]) // 3

chunk

// Takes array and size and returns chunks.
easy.chunk([1,2,3,4], 2) // [[1,2],[3,4]]

Advanced

uniq

// Takes array and removes duplicates.
easy.uniq([1,2,2,3]) // [1,2,3]

flatten

// Takes array and flattens one level.
easy.flatten([1,[2,3]]) // [1,2,3]

groupBy

// Takes array and function and groups items.
easy.groupBy([1,2,3,4], x => x % 2) // { 0:[2,4], 1:[1,3] }

sortBy

// Takes array and function and sorts by key.
easy.sortBy([3,1,2], x => x) // [1,2,3]

pick

// Takes object and keys and returns subset.
easy.pick({ a:1,b:2 }, ["a"]) // { a:1 }

omit

// Takes object and keys and omits them.
easy.omit({ a:1,b:2 }, ["b"]) // { a:1 }

Usage pattern

const easy = require("easyjs-empty");

const maths = require("easyjs-maths");
const time = require("easyjs-time");
const random = require("easyjs-random");
const date = require("easyjs-date");
const json = require("easyjs-json");
const collections = require("easyjs-collections");

// basic sets

easy.use(maths);
easy.use(time);
easy.use(random);
easy.use(date);
easy.use(json);
easy.use(collections);

// advanced sets

easy.use(maths.advanced);
easy.use(time.advanced);
easy.use(random.advanced);
easy.use(date.advanced);
easy.use(json.advanced);
easy.use(collections.advanced);