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

oap

v0.0.8

Published

Object Argument Processor

Downloads

5

Readme

OAP - Object Argument Parser

The main goal of this module is to provide a easy method for validating the existence of arguments (values) in an Object. For value validation check other modules like validator.

Travis-CI David

Status: Passively maintained

This was an early project learning Javascript. However it's still being used so I will passively maintain it.

For better solutions check:

  • [https://github.com/ansman/validate.js]
  • [https://github.com/bugventure/jsen]

What it does

  • You define a template object with the rules for your arguments
  • You pass the template and your object with arguments to oap.check()
  • Oap will test you template arguments (unless NODE_ENV matches /^prod/)
  • Oap will test your arguments against the template.
  • Oap will try to run as many tests as it can and give you a complete error list for all the arguments. This is not always possible since tests are done in stages but ..

Install

npm install oap

Example

var oap = require('oap');

function doSomeThing(args, cb) {
  var template = {
    arg1: {
      required: true,
      defined: true,
      default: 'a',
      function: testFunction,
      requires: ['arg2']
      excludes: ['arg3']
    },
    arg2: {
      required: false,
      requires: ['arg1']
    }
  };

  oap.check(args, template, function(err, result) {
    if (err) return cb(err);
    doAmazingStuff(args);
  });

  function doAmazingStuff(args) {
    ...
  }
}

Template options

The options can be passed to the template

  • required Value must be present
  • defined Value cannot be undefined
  • default Default value if not passed
  • function Custom value to pass the value to
  • requires This value requires one or more other values to be passed as well
  • excludes This value requires one or more other values not to be present

Changelog

0.0.8

  • Fix crash when NODE_ENV is not present
  • Documentation updates
  • Changed some test output for consistency

0.0.7 - Maintenance update

  • Switch to Mocha as test-suite
  • Switch to ESLint as linter
  • Fix double callback-calling on requires/excludes invalid invocation
  • Moved repository to my personal Github account
  • Add to Travis-CI

TODO

Somewhat in order - Move to Github issues later

Important

  • Make browser compatible
  • Measure and look for speed improvements

Features

  • oneOf template option: check if value is in array
  • integrate with validator for value validation

Bonus

  • split-up the check() function, it's a bit long