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.6.1 to 1.6.2

27

index.js

@@ -5,14 +5,19 @@ var inherits = require('inherits')

this.tfError = Error.call(this)
this.tfType = type
this.tfValue = value
var message
Object.defineProperty(this, 'message', {
get: function () {
if (message) return message
message = tfErrorString(type, value)
if (arguments.length === 1 && typeof type === 'string') {
this.message = type
} else {
this.tfType = type
this.tfValue = value
return message
}
})
var message
Object.defineProperty(this, 'message', {
get: function () {
if (message) return message
message = tfErrorString(type, value)
return message
}
})
}
}

@@ -226,3 +231,3 @@

quacksLike: function quacksLike (type) {
function quacksLike (value, strict) {
function quacksLike (value) {
return type === getValueTypeName(value)

@@ -229,0 +234,0 @@ }

{
"name": "typeforce",
"version": "1.6.1",
"version": "1.6.2",
"description": "Another biased type checking solution for Javascript",

@@ -5,0 +5,0 @@ "author": "Daniel Cousens",

@@ -69,6 +69,6 @@ # typeforce

var fastType = typeforce.compile(type)
// fastType => {
// fastType => typeforce.object({
// foo: typeforce.Number,
// bar: typeforce.maybe(typeforce.String)
// }
// })

@@ -75,0 +75,0 @@ // use strictness for recursive types to enforce whitelisting properties

@@ -45,2 +45,29 @@ /* global describe, it */

})
describe('custom errors', function () {
var err = new typeforce.TfTypeError('custom error')
var everFailingType = function () { throw new typeforce.TfTypeError('custom error') }
it('has the custom message', function () {
assert(err.message === 'custom error')
})
it('is instance of TfTypeError', function () {
assert(err instanceof typeforce.TfTypeError)
})
it('assert.throws knows how to handle it', function () {
assert.throws(function () {
typeforce(everFailingType, 'value')
}, new RegExp('custom error'))
})
it('is caught in oneOf', function () {
assert(!typeforce.oneOf(everFailingType)('value'))
})
it('does not break oneOf', function () {
assert(!typeforce.oneOf(everFailingType, typeforce.string)('value'))
})
})
})
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