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

typeforce

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeforce - npm Package Compare versions

Comparing version 1.10.5 to 1.10.6

66

index.js

@@ -1,12 +0,12 @@

var errors = require('./errors')
var native = require('./native')
var ERRORS = require('./errors')
var NATIVE = require('./native')
// short-hand
var tfJSON = errors.tfJSON
var TfTypeError = errors.TfTypeError
var TfPropertyTypeError = errors.TfPropertyTypeError
var tfSubError = errors.tfSubError
var getValueTypeName = errors.getValueTypeName
var tfJSON = ERRORS.tfJSON
var TfTypeError = ERRORS.TfTypeError
var TfPropertyTypeError = ERRORS.TfPropertyTypeError
var tfSubError = ERRORS.tfSubError
var getValueTypeName = ERRORS.getValueTypeName
var types = {
var TYPES = {
arrayOf: function arrayOf (type) {

@@ -16,3 +16,3 @@ type = compile(type)

function _arrayOf (array, strict) {
if (!native.Array(array)) return false
if (!NATIVE.Array(array)) return false

@@ -36,3 +36,3 @@ return array.every(function (value, i) {

function _maybe (value, strict) {
return native.Null(value) || type(value, strict, maybe)
return NATIVE.Null(value) || type(value, strict, maybe)
}

@@ -49,4 +49,4 @@ _maybe.toJSON = function () { return '?' + tfJSON(type) }

function _map (value, strict) {
if (!native.Object(value, strict)) return false
if (native.Null(value, strict)) return false
if (!NATIVE.Object(value, strict)) return false
if (NATIVE.Null(value, strict)) return false

@@ -92,4 +92,4 @@ for (var propertyName in value) {

function _object (value, strict) {
if (!native.Object(value)) return false
if (native.Null(value)) return false
if (!NATIVE.Object(value)) return false
if (NATIVE.Null(value)) return false

@@ -125,6 +125,6 @@ var propertyName

oneOf: function oneOf () {
var _types = [].slice.call(arguments).map(compile)
var types = [].slice.call(arguments).map(compile)
function _oneOf (value, strict) {
return _types.some(function (type) {
return types.some(function (type) {
try {

@@ -137,3 +137,3 @@ return typeforce(type, value, strict)

}
_oneOf.toJSON = function () { return _types.map(tfJSON).join('|') }
_oneOf.toJSON = function () { return types.map(tfJSON).join('|') }

@@ -153,6 +153,6 @@ return _oneOf

tuple: function tuple () {
var _types = [].slice.call(arguments).map(compile)
var types = [].slice.call(arguments).map(compile)
function _tuple (values, strict) {
return _types.every(function (type, i) {
return types.every(function (type, i) {
try {

@@ -165,3 +165,3 @@ return typeforce(type, values[i], strict)

}
_tuple.toJSON = function () { return '(' + _types.map(tfJSON).join(', ') + ')' }
_tuple.toJSON = function () { return '(' + types.map(tfJSON).join(', ') + ')' }

@@ -182,19 +182,19 @@ return _tuple

function compile (type) {
if (native.String(type)) {
if (type[0] === '?') return types.maybe(compile(type.slice(1)))
if (NATIVE.String(type)) {
if (type[0] === '?') return TYPES.maybe(compile(type.slice(1)))
return native[type] || types.quacksLike(type)
} else if (type && native.Object(type)) {
if (native.Array(type)) return types.arrayOf(compile(type[0]))
return NATIVE[type] || TYPES.quacksLike(type)
} else if (type && NATIVE.Object(type)) {
if (NATIVE.Array(type)) return TYPES.arrayOf(compile(type[0]))
return types.object(type)
} else if (native.Function(type)) {
return TYPES.object(type)
} else if (NATIVE.Function(type)) {
return type
}
return types.value(type)
return TYPES.value(type)
}
function typeforce (type, value, strict, surrogate) {
if (native.Function(type)) {
if (NATIVE.Function(type)) {
if (type(value, strict)) return true

@@ -210,8 +210,8 @@

// assign types to typeforce function
for (var typeName in native) {
typeforce[typeName] = native[typeName]
for (var typeName in NATIVE) {
typeforce[typeName] = NATIVE[typeName]
}
for (typeName in types) {
typeforce[typeName] = types[typeName]
for (typeName in TYPES) {
typeforce[typeName] = TYPES[typeName]
}

@@ -218,0 +218,0 @@

{
"name": "typeforce",
"version": "1.10.5",
"version": "1.10.6",
"description": "Another biased type checking solution for Javascript",

@@ -5,0 +5,0 @@ "keywords": [

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