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.5.0 to 1.5.1

8

package.json
{
"name": "types.js",
"version": "1.5.0",
"description": "A tiny (1.9kb) Javascript type checker/enforcer library",
"version": "1.5.1",
"description": "A tiny (~2kb) Javascript type checker/enforcer library",
"main": "types.min.js",

@@ -31,5 +31,3 @@ "scripts": {

},
"homepage": "https://github.com/phazelift/types.js",
"dependencies": {},
"devDependencies": {}
"homepage": "https://github.com/phazelift/types.js"
}
types.js
========
<br/>
A tiny (2.2Kb) Javascript type checker/enforcer library.
A tiny (2.2kB) Javascript type checker/enforcer library.

@@ -9,3 +9,3 @@ - fixes NaN, array, null, etc..

- 4 convenience forms: isNumber, notNumber, hasNumber and allNumber (with any type of choice)
- can force a value to be of some type, with optional value if conversion is not possible
- can force a value to be of some type, with optional value if conversion fails

@@ -33,4 +33,4 @@ ___

A quick example to show how we can safely call a function that needs to pass a number argument, first in standard JS, next with
types.js force methods:
A quick example to show how we can safely call a function that needs to pass a number argument, first in
standard JS, next with types.js force methods:
```javascript

@@ -65,14 +65,13 @@ var left = '500px'

For use with node.js you can install with `npm install types.js`
___
**AMD**
When using AMD, you can load types.js like so:
```javascript
require.config({
paths: {
'types', [ 'path/to/types.min' ]
'types', [ 'path/to/types.min(.js)' ]
}
});
require( ['types'], function( Types ){
console.log( Types.isNumber(0) );
require( ['types'], function( _ ){
console.log( _.isNumber(0) );
// true

@@ -95,5 +94,7 @@ });

**typeof** Returns a lowercase string representation of the type of the argument value, according to types.js type-definitions.
**intoArray** Converts arguments or space delimited strings into an array.
___
**more examples:**
**some more examples:**
```javascript

@@ -114,2 +115,5 @@ var _= Types; // browser

_.forceArray("you'll get an array!"); // []
_.intoArray( 'hi', 'there' ); // [ 'hi', 'there' ]
_.intoArray( ' hi there ' ); // [ 'hi', 'there' ]
_.intoArray( '', 0, {}, [] ); // [ '', 1, {}, [] ]

@@ -119,3 +123,3 @@ var func= null;

// call a function that might not exist anymore:
_.forceFunction( func )( 'arguments for func, or replacement' );
_.forceFunction( func )( 'arguments for func' );
// no crash, default empty function is called, returns undefined

@@ -122,0 +126,0 @@

Sorry, the diff of this file is not supported yet

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