Socket
Socket
Sign inDemoInstall

@appliedblockchain/assert-combinators

Package Overview
Dependencies
Maintainers
15
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appliedblockchain/assert-combinators - npm Package Compare versions

Comparing version 1.0.0 to 1.1.1

helpers/rethrow.js

13

array.js
// @flow strict
const mixed = require('./mixed')
const rethrow = require('./helpers/rethrow')
const array /*: <T>(a?: mixed => T) => (mixed => $ReadOnlyArray<T>) */ = /*:: <T> */
const array /*: <T>(a?: mixed => T) => (mixed => T[]) */ = /*:: <T> */
(a = mixed) =>

@@ -12,4 +13,12 @@ value => {

if (a && a !== mixed) {
value.every(_ => a(_))
value.forEach((_, i) => {
try {
a(_)
} catch (err) {
rethrow(`[${i}]`)(err)
}
})
}
// $FlowFixMe
return value

@@ -16,0 +25,0 @@ }

# Changelog
## [v1.1.1](../../compare/v1.1.0...v1.1.1) (2020-04-02)
* Fixing flow errors.
* Updating changelog.
## [v1.1.0](../../compare/v1.0.0...v1.1.0) (2020-04-02)
* Adding predicate. Using flow strict mode.
* Adding nil, null and undefined.
* Including nested keys in error message. Don't enforce read only array.
* Updating changelog.
## [v1.0.0](../../compare/v0.0.3...v1.0.0) (2020-03-31)

@@ -4,0 +16,0 @@

21

exact.js

@@ -1,2 +0,2 @@

// @flow
// @flow strict

@@ -6,15 +6,20 @@ const { inspect } = require('util')

const exact /*: <KV: {}>(KV) => any => $ObjMapi<$Exact<KV>, <K, V>(K, (...Iterable<any>) => V) => V> */ = /*:: <KV> */
const exact /*: <KV: {}>(KV) => mixed => $ObjMapi<$Exact<KV>, <K, V>(K, (...Iterable<mixed>) => V) => V> */ = /*:: <KV> */
(kvs) =>
value => {
if (value === null || typeof value !== 'object') {
throw new TypeError(`Expected object, got ${inspect(value)}.`)
}
const result = object(kvs)(value)
const keys = Object.keys(value)
for (const key of keys) {
if (!Object.prototype.hasOwnProperty.call(kvs, key)) {
throw new TypeError(`Expected object with ${key} property in ${inspect(value)}.`)
}
const keys = Object
.keys(value)
.filter(key => !Object.prototype.hasOwnProperty.call(kvs, key))
if (keys.length) {
throw new TypeError(`Unexpected extra keys ${keys.map(String).join(', ')} in ${inspect(value)}.`)
}
return (result /*: any */)
// $FlowFixMe
return result
}
module.exports = exact

@@ -1,8 +0,8 @@

// @flow
// @flow strict
const { inspect } = require('util')
const finite /*: any => number */ =
const finite /*: mixed => number */ =
value => {
if (!Number.isFinite(value)) {
if (typeof value !== 'number' || !Number.isFinite(value)) {
throw new TypeError(`Expected finite number, got ${inspect(value)}.`)

@@ -9,0 +9,0 @@ }

@@ -1,2 +0,2 @@

// @flow
// @flow strict

@@ -11,3 +11,5 @@ const and = require('./and')

const mixed = require('./mixed')
const nil = require('./nil')
const nilOr = require('./nil-or')
const null_ = require('./null')
const nullOr = require('./null-or')

@@ -17,2 +19,3 @@ const number = require('./number')

const or = require('./or')
const predicate = require('./predicate')
const shape = require('./shape')

@@ -22,2 +25,3 @@ const string = require('./string')

const tuple = require('./tuple')
const undefined_ = require('./undefined')
const undefinedOr = require('./undefined-or')

@@ -34,3 +38,5 @@

mixed,
nil,
nilOr,
null: null_,
nullOr,

@@ -40,2 +46,3 @@ number,

or,
predicate,
shape,

@@ -45,3 +52,4 @@ string,

tuple,
undefined: undefined_,
undefinedOr
}
// @flow strict
const { inspect } = require('util')
const rethrow = require('./helpers/rethrow')

@@ -9,3 +10,3 @@ const object /*: <KV: { ... }>(KV) => mixed => $ObjMapi<KV, <K, V>(K, (...Iterable<mixed>) => V) => V> */ = /*:: <KV> */

if (value == null || typeof value !== 'object') {
throw new TypeError('Expected object.')
throw new TypeError(`Expected object, got ${inspect(value)}.`)
}

@@ -15,5 +16,9 @@ for (const k of Object.keys(kvs)) {

if (typeof v === 'function') {
v(value[k])
try {
v(value[k])
} catch (err) {
rethrow(`[${k}]`)(err)
}
} else if (v !== value[k]) {
throw new TypeError(`Expected ${k} to be ${inspect(v)}, got ${inspect(value[k])}.`)
throw new TypeError(`Expected ${inspect(k)} to be ${inspect(v)}, got ${inspect(value[k])} in ${inspect(value)} object.`)
}

@@ -20,0 +25,0 @@ }

@@ -1,2 +0,2 @@

// @flow
// @flow strict

@@ -7,3 +7,3 @@ const { inspect } = require('util')

type $A<R> = any => R
type $A<R> = mixed => R

@@ -10,0 +10,0 @@ declare function or<A>($A<A>): $A<A>;

{
"name": "@appliedblockchain/assert-combinators",
"version": "1.0.0",
"version": "1.1.1",
"description": "Assertion combinators.",

@@ -21,2 +21,8 @@ "main": "index.js",

},
"jest": {
"testPathIgnorePatterns": [
"/node_modules/",
"/wip/"
]
},
"eslintConfig": {

@@ -23,0 +29,0 @@ "extends": "@appliedblockchain"

@@ -1,4 +0,4 @@

// @flow
// @flow strict
const shape /*: <KV: {}>(KV) => any => $Shape<$ObjMapi<KV, <K, V>(K, (...Iterable<any>) => V) => V>> */ = /*:: <KV> */
const shape /*: <KV: {}>(KV) => mixed => $Shape<$ObjMapi<KV, <K, V>(K, (...Iterable<mixed>) => V) => V>> */ = /*:: <KV> */
(kvs) =>

@@ -5,0 +5,0 @@ value => {

@@ -1,2 +0,2 @@

// @flow string
// @flow strict

@@ -3,0 +3,0 @@ const { inspect } = require('util')

@@ -1,2 +0,2 @@

// @flow
// @flow strict

@@ -7,3 +7,3 @@ const { inspect } = require('util')

type $A<R> = any => R
type $A<R> = mixed => R
type $R<T,V> = $ReadOnly<{| tag: T, value: V |}>

@@ -10,0 +10,0 @@

@@ -1,2 +0,2 @@

// @flow
// @flow strict

@@ -8,3 +8,3 @@ const { inspect } = require('util')

type $A<R> = any => R
type $A<R> = mixed => R

@@ -11,0 +11,0 @@ declare function tuple<A>($A<A>): $A<[A]>;

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