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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dissmatch

v0.0.1

Published

negatively match objects

Downloads

3

Readme

#Dissmatch negatively match objects (note: this documentation is in a very rough state. Many parts are illegible.) ##About It is often infiesable to match entire objects. Dissmatch does not try to match the whole object. Instead, it matches a given object agains a pattern and returns a value only when there is a violation of the pattern. If there are parts of the object that are not defined in the pattern, dismatch simply ignores them.

##Installation In your project's directory on the command line:

npm install --save dissmatch

In your project file:

var dissmatch = require('dissmatch');
//work your magic here...

##API

###dissmatch is a single function:

/**
*
*@param subject - Object
*@param pattern - Object
*/
var dissmatch = function(subject, pattern,[pattern2, pattern3...])

###subject subject can be any javascript object

###Pattern pattern is a specifically designed javascript object. Multiple patterns can be included and will be matched sequentially.

var matchErrors =
  dissmatch(subject, pattern1) ||
  dissmatch(subject, pattern2) ||
  dissmatch(subject, pattern3);

is equivalent to

var matchErrors =
  dissmatch(
    subject, pattern1, pattern2, pattern3);

####Types Each key within a pattern points to an object. The type of object determines how it matches against the value at the same key in the original subject.

#####Boolean Booleans define presence

  • true -- return an error only if the key DOES NOT exist
  • false -- return an error only if the key DOES exist

#####RegExp Regular Expressions will return an error only if the value in the subject DOES NOT match.

#####Array Expect an error only if the original value is not equal (===) to at least one of the values in the array. Functions take two arguments, the value and the subject (value, subject) => :Error?

#####Function Functions can define complex behavior and should be used with caution. Other Types can be simulated/extended using functions. Functions SHOULD be designed to evaluate a value and return a error only if the value fails evaluation. Functions take two arguments, the value and the subject (value, subject) => :Error?

#####Object Nesting patterns within objects allows the testing of nested subjects.