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

assume

Package Overview
Dependencies
Maintainers
4
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assume - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

25

index.js

@@ -497,2 +497,27 @@ 'use strict';

/**
* Assert that the value is either one of the given values.
*
* @param {Arguments} .. All the values it can match
* @returns {Assert}
* @api public
*/
Assert.add('either', function either() {
var args = Array.prototype.slice.call(arguments, 0)
, i = args.length
, result = false
, expect = [];
while (i-- || result) {
if (!this.deeply) result = this.value === args[i];
else result = deep(this.value, args[i]);
if (result) break;
expect.push(string(args[i]));
}
expect = '`'+ string(this.value) +'` to equal either `'+ expect.join('` or `') +'`';
return this.test(result, '', expect);
});
/**
* Validate the assertion.

@@ -499,0 +524,0 @@ *

2

package.json
{
"name": "assume",
"version": "0.0.14",
"version": "0.0.15",
"description": "Expect-like assertions that works seamlessly in node and browsers",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -37,2 +37,29 @@ # assume

## Table of Contents
- [Syntax](#syntax)
- [Configuration](#configuration)
- [Assertion](#assertion)
- [a, an](#a-an)
- [instanceOf, instanceof, inherits, inherit](#instanceof-instanceof-inherits-inherit)
- [include, includes, contain, contains](#include-includes-contain-contains)
- [ok, okay, truthy, truely](#ok-okay-truthy-truely)
- [falsely, falsey](#falsely-falsey)
- [true](#true)
- [false](#false)
- [exists, exist](#exists-exist)
- [length, lengthOf, size](#length-lengthof-size)
- [empty](#empty)
- [above, gt, greater, greaterThan](#above-gt-greater-greaterthan)
- [least, gte, atleast](#least-gte-atleast)
- [below, lt, less, lessThan](#below-lt-less-lessthan)
- [most, lte, atmost](#most-lte-atmost)
- [within, between](#within-between)
- [hasOwn, own, ownProperty, haveOwnProperty, property, owns, hasown](#hasown-own-ownproperty-haveownproperty-property-owns-hasown)
- [match, matches](#match-matches)
- [equal, equals, eq, eqs](#equal-equals-eq-eqs)
- [eql, eqls](#eql-eqls)
- [either](#either)
- [i.hope](#ihope)
## Syntax

@@ -231,3 +258,3 @@

#### above, gt, greater, greaterTHan
#### above, gt, greater, greaterThan

@@ -321,2 +348,12 @@ Assert if the value is above the given value. If you need greater or equal check

#### either
Assert that the value is either one of the given values. It can be prefixed with
`.deep` for deep assertions.
```js
assume('foo').is.either('bar', 'banana', 'foo');
assume({ foo: 'bar' }).is.either('bar', 'banana', { foo: 'bar' });
```
### i.hope

@@ -323,0 +360,0 @@

@@ -642,2 +642,18 @@ if ('undefined' === typeof global) global = (function that() {

describe('#either', function () {
it('equals one of the given values', function (next) {
assume('bar').is.either('foo', 'bar');
try { assume('bar').is.either(1, 2, new Date(), []); }
catch (e) { next(); }
});
it('deeply equals one of the given values', function (next) {
assume({foo: 'bar'}).is.deep.either({ bar: 'foo' }, { foo: 'bar' });
try { assume({foo: 'bar'}).is.deep.either({ bar: 'foo' }, { foo: 'bar', food: 'bar' }); }
catch (e) { next(); }
});
});
describe('.plan', function () {

@@ -644,0 +660,0 @@ it('plans the amount of asserts to execute', function (next) {

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