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

common-filters

v0.0.7

Published

Library with common filters

Readme

common-filters

Library with common filters

NPM version Build status

Note: This module works in browsers and Node.js >= 4.0

Installation

npm install common-filters

Usage

const filters = require('common-filters');

filters.toString(['a', 'b', 'c']); //'abc'

filters.round('0.105', -2); //0.11

API

Filters.add

Use this methods for adding custom filters in simple format.

Filters.add('trim', trim);
//or
Filters.add({
  toLowerCase: toLowerCase,
  toUpperCase: toUpperCase
});

Also you can use Object.assign(commonFilters, customFilters) in other situations

Filters.filterName(value, [arg], [options])

  • value (Any) - Filtered value

  • arg (Any) - Value for comparison. Can not be an object or undefined. User can set it as options.arg. If you use 'arg' in your filter you must be sure that user will specify this value

  • options (Object) - Options

    • arg (Any) - Will be set if arg is specified
    • (Any) - Any custom options
  • (Any) - Any custom arguments

  • return (Any) - Filtered value

Filters:

Types

  • toObject - convert value to object

  • toArray - convert value to array

  • castArray - wrap value to array if it's not one

  • toNumber - convert value to number

  • toFinite - convert value to finite number

  • toInteger - convert value to integer

  • toString - convert value to string

  • toDate - convert value to date

  • toBoolean - convert value to boolean

  • toUndefined - convert value to undefined

Numbers (other types are not filtered)

  • round - round number

    • arg (Number or String) - precision
  • range - return default value if no number or number is not in range

    • from (Number) - left boarder of range
    • to (Number) - right boarder of range
    • default (Any) - default value

Strings (other types are not filtered)

  • trim - trim value

  • prefix - add prefix to value

    • arg (String) - prefix
  • postfix - add postfix to value

    • arg (String) - postfix
  • shorten - shorten string by specific length and change end to '...'

    • arg (String) - length
  • toLowerCase - convert value to lower case

  • toUpperCase - convert value to upper case

  • toCamelCase - convert common strings, dashes-strings or shakes_strings to camelCaseStrings

  • replace - replace by pattern

    • pattern (RegExp or String) - RegExp
    • replacement (String) - replacement
  • split - split string by separator to array

    • arg (String) - separator
  • reverse - reverse string

  • slice - get substring

    • begin (Number) - start index
    • end (Number) - end index

Array (other types are not filtered)

  • join - join string by separator to string

    • arg (String) - separator
  • reverse - reverse array

  • slice - get sub array

    • begin (Number) - start index
    • end (Number) - end index

Tests

npm install
npm test

License

MIT