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

types.js

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

types.js - npm Package Compare versions

Comparing version 1.3.6 to 1.3.7

2

package.json
{
"name": "types.js",
"version": "1.3.6",
"version": "1.3.7",
"description": "A tiny (1.8kb), but essential Javascript type-check library",

@@ -5,0 +5,0 @@ "main": "types.min.js",

@@ -46,2 +46,25 @@ types.js

Check it out, it's sweet! I've added force to types.js because I use it all the time and it seems to belong in here.
____________________________________________________________
**Number.void**<br/>
Make a numberFilter for arguments with the new forceNumber:
```javascript
function numberFilter(){
var numbers= [];
for( var arg in arguments ){
var value= _.forceNumber( arguments[arg] );
if( value.void )
continue;
numbers.push( value );
}
return numbers;
}
function someFunc(){
return numberFilter.apply( this, arguments );
}
console.log( someFunc('ignore', 1, 'the', 2, 'strings!', 3) );
// [ 1, 2, 3 ]
console.log( someFunc('1 but', '2 not', '3 unconditional!') );
// [ 1, 2, 3 ]
```
___

@@ -54,9 +77,9 @@ For use with node.js you can install with `npm install types.js`

**forceString** Forces a value to be of a given type, and returns that value, a replacement, or it's literal default.
**force'Type'** Forces a value to be of a given type, and returns that value, a replacement, or it's literal default.
**isString** and **notString** (and the other is and not-types) are useful for single argument type checking.
**is'Type'** and **not'Type'** are useful for single argument type checking.
**allString** (and the other all-types) are useful for checking if all given arguments are of a certain type.
**all'Type'** are useful for checking if all given arguments are of a certain type.
**hasString** (and the other has-types) are useful for checking if one or more arguments are of a certain type.
**has'Type'** are useful for checking if one or more arguments are of a certain type.

@@ -66,3 +89,3 @@ **typeof** Returns a lowercase string representation of the type of the argument value, according to types.js type-definitions.

**some examples:**
**some more examples:**
```javascript

@@ -247,2 +270,4 @@ var _= Types; // browser

Just use: `_.forceNumber( value, 0 );` to return a 0 as replacement, it only is not default anymore.
I made this change because I wanted to be able to check if forceNumber was successful. Just a 0 can be very misleading and

@@ -249,0 +274,0 @@ a source for bugs. NaN is a failure IMO, so I made a kind of replacement feature in forceNumber.

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