You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

arghh

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arghh

Object argument signature check

2.0.1
latest
Source
npm
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

Arghh

Object argument signature check

Example (example.js)

// This is an example from the Google Knowledge Graph API
// https://developers.google.com/knowledge-graph/?hl=en

// - key and one of query or ids are required arguments
// - languages, types, indent, prefix, and limit are all optional
// - key, languages, indent, and prefix receive default values when omitted
var Arghh = require('arghh');
var Assert = require('assert');

var arghh = Arghh({
  required : ['key', ['query', 'ids']],
  optional : ['languages', 'types', 'indent', 'prefix', 'limit'],
  defaults : {
      key       : 'jk283h43lka3h2hq',
      languages : 'en',
      indent    : false,
      prefix    : true
  }
});

var result = arghh({
  query   : 'honkey',
  limit   : 100,
  prefix  : false,
  ignored : 20
});

Assert.deepEqual(result, {
  query     : 'honkey',
  limit     : 100,
  key       : 'jk283h43lka3h2hq',
  languages : 'en',
  indent    : false,
  prefix    : false
});

Assert.throws(function () {
  arghh({
    key : 'abcdefg'
  });
}, 'Must pass one of [query, ids]');

FAQs

Package last updated on 31 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts