Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blork

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blork - npm Package Compare versions

Comparing version 4.4.1 to 4.5.0

test/exports.checker.test.js

17

lib/classes/Blorker.js

@@ -67,2 +67,19 @@ // @flow

/**
* Return a specific checker.
* @param {string|Function|Array|Object} type A single stringy type reference (e.g. 'str'), functional shorthand type reference (e.g. `String`), or an object/array with list of types (e.g. `{name:'str'}` or `['str', 'num']`).
* @return {function} The specified checker or undefined if it doesn't exist.
*/
checker(type) {
// Check args.
runChecker(this._checkers.string, type, "arguments[0]", BlorkError);
// Return the checker.
const checker = this._checkers[type];
if (checker) return checker;
// Not found.
throwError(BlorkError, "Checker not found", type, "arguments[0]");
}
/**
* Check values against types.

@@ -69,0 +86,0 @@ * Throws an error if a value doesn't match a specified type.

3

lib/exports.js

@@ -9,3 +9,3 @@ const ValueError = require("./errors/ValueError");

// Make a default instance.
const { args, check, add, throws } = blork();
const { args, check, add, checker, throws } = blork();

@@ -17,2 +17,3 @@ // Exports.

exports.add = add;
exports.checker = checker;
exports.throws = throws;

@@ -19,0 +20,0 @@ exports.format = format;

@@ -20,5 +20,6 @@ const Blorker = require("../classes/Blorker");

args: blorker.args.bind(blorker),
throws: blorker.throws.bind(blorker),
add: blorker.add.bind(blorker)
add: blorker.add.bind(blorker),
checker: blorker.checker.bind(blorker),
throws: blorker.throws.bind(blorker)
};
};
{
"name": "blork",
"description": "Blork! Mini runtime type checking in Javascript",
"version": "4.4.1",
"version": "4.5.0",
"license": "0BSD",

@@ -6,0 +6,0 @@ "author": "Dave Houlbrooke <dave@shax.com>",

@@ -518,2 +518,4 @@ # Blork! Mini runtime type checking in Javascript

- 4.5.0
- Add `checker()` function to return the boolean checker function itself.
- 4.4.0

@@ -520,0 +522,0 @@ - Add `json` checker to check for JSON-friendly values (null, true, false, finite numbers, strings, plain objects, plain arrays)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc