![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
⚠️ DEPRECATED ⚠️
This module has been deprecated. You should lock your version to
0.3.3
. It will be replaced by a different module.
Convenient high-performance type-checking for JavaScript
value is designed to ease type-checking in JavaScript while keeping performance in mind. It comes with a fluent api to improve the readability of your code. Use value to sanitize function parameters and to provide better error messages if some type is unexpected.
npm install value@0.3.3
**It's important to use this version number because newer versions will be an entire
If you're not using a CommonJS-system in the browser value is namespaced under window.jhnns.value
.
var value = require("value");
// value takes every possible type in JavaScript
// and provides some methods to test for the type.
value(undefined).typeOf(Object); // = false
value(null).typeOf(Object); // = false
value([]).typeOf(Array); // = true
value([]).typeOf(Object); // = false
value(2).typeOf(Number); // = true
value(new String("hello")).typeOf(String); // = true
value(new String("hello")).typeOf(Object); // = false
value(/myRegExp/).typeOf(RegExp); // = true
value(document.createElement("a")).typeOf(HTMLAnchorElement); // = true
// value also provides a negation for better readability
value(2).notTypeOf(String); // = true
// you can also check conveniently for null and undefined with one call
value(undefined).isSet(); // = false
value(null).isNotSet(); // = true
// value also supports convenient type-checking within collections
value([1, 2, 3]).each.typeOf(Number); // = true
value([1, "2", 3]).any.notTypeOf(Number); // = true
value({ one: 1, two: 2, three: null }).any.isNotSet(); // = true
Tests if the subject is a child of the constructor. Respects the complete inheritance chain. Keep in mind that everything that is neither null nor undefined is a child of Object (see below).
Negation of typeOf()
Returns true when the subject is neither null
nor undefined
Negation of isSet()
Invokes value(item).typeOf(constructor)
on every item within the given collection. Returns true if every item returned true. A collection can be an array or an object.
Invokes the value(item).isSet() on every item within the given collection. Returns true if every item returned true. A collection can be an array or an object.
Negation of each.typeOf()
Negation of each.isSet()
Returns subject.constructor
or null
if the subject was null
or undefined
.
value contains a set of opinionated presumptions to avoid common and annoying pitfalls. It has been designed to act like you would expect from a language like ActionScript with optional static types. The returned result is not always conform with the JavaScript type-specification.
This is a collection of cases where value acts differently to the original typeof
-operator:
In contrast to typeof null === "object"
value(null).typeOf(Object); // = false
In constrast to typeof new String() === "object"
value(new String()).typeOf(String); // = true
value(new String()).typeOf(Object); // = false
In constrast to typeof [] === "object"
value([]).typeOf(Object); // = false
value([]).typeOf(Array); // = true
In constrast to typeof NaN === "number"
and typeof Infinity === "number"
value(NaN).typeOf(Number); // = false
value(Infinity).typeOf(Number); // = false
While NaN
and Infinity
are numbers from a theoretical point of view it's a common mistake when trying to sanitize calculation parameters. value assumes that numbers are numeric - that's why NaN
and Infinity
are not numbers.
This stays the same: value(arguments).typeOf(Array)
will return false because arguments
doesn't provide all methods of Array
.
FAQs
Convenient type-checking in JavaScript
The npm package value receives a total of 41 weekly downloads. As such, value popularity was classified as not popular.
We found that value demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.