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 🙏

© 2025 – Pkg Stats / Ryan Hefner

the-value

v1.1.2

Published

value utility. functional, semantic and neat.

Readme

The Value

functional, semantic and neat.

npm i -S the-value

Usage

const Value = require('the-value')
Value(1).Number // true
Value(1).range(0, 1) // true
Value('b').between('a', 'c') // true
Value.is(200, Value.Constant(200)) // true
Value(200).is(Value.Constant(200)) // true

All original provided functions in here

Addon

! All functions should have the first parameter to be the target value (to conduct operations).

addon(utilsObject: object, keys?: string[]|Record<string, string>, type?: 'getter', notCacheGetter?: boolean=false)

  • utilsObject, properties owner.
  • keys, list properties should be added. If ignored, all own enumerable properties will added. Properties will be renamed with the option is not an array.
  • type, if set to be getter, indicate the function type properties should be converted to getter properties.
  • notCacheGetter, if set to be true, indicate the getter properties should not be cached.

All of own enumerable properties:

// * addon() of the top level `Value` will return a new `Value`, to avoid pollute the package source when it's imported in other files.
const NewValue = Value.addon({
  pow(v, n) { return v ** n },
  get Square(v) { return v ** 2 },
  VERSION: '1.0',
})

NewValue(2).pow(2) // 4
NewValue(2).Square // 4
NewValue(2).VERSION // 1.0

// addon() of new `Value` will addon itself (instead of returning a new one).
const NewValue2 = NewValue.addon({})

newValue2 === newValue // true

Specific properties (even non-enumerable or inherited):

const NewValue = Value.addon({
  pow(v, n) { return v ** n },
  get Square(v) { return v ** 2 },
  VERSION: '1.0',
}, ['pow'])

Make function to be getter:

const NewValue = Value.addon({
  square(v) { return v ** 2 },
}, ['square'], 'getter')

NewValue(2).square // 4

Rename:

const NewValue = Value.addon({
  square(v) { return v ** 2 },
}, { square: 'Square' }, 'getter')

NewValue(2).Square // 4

Disable cache of getter properties when add on (cache getter properties is default option of addon(), see declaration):

let count = 0
const NewValue = Value.addon({
  square(v) { count++; return v ** 2 },
}, { square: 'Square' }, 'getter', true)

const v = NewValue(2)
v.Square // count is 1
v.Square // count is 2
v.Square // count is 3
v.Square // count is 4

Add utils from lodash/underscore/...

const underscore = require('underscore')
const Value = require('the-value')
  .addon(underscore, ['pick', 'omit', 'shuffle'])
  .addon(underscore, { isElement: 'Element' }, 'getter')