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

occamsrazor-match

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

occamsrazor-match - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

extra/everyValues.js

2

extra/every.js
var arrayOf = require('./arrayOf');
module.exports = function some(args) {
module.exports = function every(args) {
return arrayOf(args, false);
};
{
"name": "occamsrazor-match",
"version": "4.0.0",
"version": "4.1.0",
"description": "helper library for writing validators",

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

@@ -37,2 +37,4 @@ occamsrazor-match

var every = require('occamsrazor-match/extra/every');
var someValues = require('occamsrazor-match/extra/someValues');
var everyValues = require('occamsrazor-match/extra/everyValues');
var greaterThan = require('occamsrazor-match/extra/greaterThan');

@@ -185,5 +187,5 @@ var lessThan = require('occamsrazor-match/extra/lessThan');

some/every
==========
This couple of validators can be used to validate arrays. It takes a validator as argument (it uses "match" behind the scene) and checks the array items against that validator. In the case of "some", at least a check should pass to return true. In the case of "every", all of them should pass.
some/every and someValues/everyValues
=====================================
some/every validates arrays. It takes a validator as argument (it uses "match" behind the scene) and checks the array items against that validator. In the case of "some", at least a check should pass to return true. In the case of "every", all of them should pass.
```js

@@ -201,2 +203,3 @@ var atLeastOne5 = some(5);

```
someValues and everyValues do the same on all values of an object.

@@ -203,0 +206,0 @@ greaterThan, lessThan

@@ -11,2 +11,4 @@ var assert = require('chai').assert;

var some = require('../extra/some');
var everyValues = require('../extra/everyValues');
var someValues = require('../extra/someValues');
var isUndefined = require('../extra/isUndefined');

@@ -120,7 +122,7 @@ var greaterThan = require('../extra/greaterThan');

describe('arrayOf', function () {
describe('every', function () {
var areFive;
before(function () {
areFive = arrayOf(5);
areFive = every(5);
});

@@ -143,53 +145,93 @@

});
it('must not match (3)', function () {
assert.isTrue(areFive([]));
});
});
describe('every', function () {
describe('some', function () {
var someFive;
before(function () {
someFive = some(5);
});
it('must match', function () {
assert.isTrue(someFive([5]));
});
it('must match (2)', function () {
assert.isTrue(someFive([5, 5]));
});
it('must not match', function () {
assert.isFalse(someFive([3]));
});
it('must not match (2)', function () {
assert.isTrue(someFive([5, 3]));
});
it('must not match (3)', function () {
assert.isTrue(someFive([3, 5]));
});
it('must not match (4)', function () {
assert.isFalse(someFive([]));
});
});
describe('everyValues', function () {
var areFive;
before(function () {
areFive = every(5);
areFive = everyValues(5);
});
it('must match', function () {
assert.isTrue(areFive([5]));
assert.isTrue(areFive({v: 5}));
});
it('must match (2)', function () {
assert.isTrue(areFive([5, 5]));
assert.isTrue(areFive({ v: 5, v1: 5 }));
});
it('must not match', function () {
assert.isFalse(areFive([3]));
assert.isFalse(areFive({ v: 3 }));
});
it('must not match (2)', function () {
assert.isFalse(areFive([5, 3]));
assert.isFalse(areFive({ v: 5, v1: 3 }));
});
it('must not match (3)', function () {
assert.isTrue(areFive({}));
});
});
describe('some', function () {
describe('someValues', function () {
var someFive;
before(function () {
someFive = some(5);
someFive = someValues(5);
});
it('must match', function () {
assert.isTrue(someFive([5]));
assert.isTrue(someFive({ v: 5 }));
});
it('must match (2)', function () {
assert.isTrue(someFive([5, 5]));
assert.isTrue(someFive({ v: 5, v1: 5 }));
});
it('must not match', function () {
assert.isFalse(someFive([3]));
assert.isFalse(someFive({ v: 3 }));
});
it('must not match (2)', function () {
assert.isTrue(someFive([5, 3]));
assert.isTrue(someFive({ v: 5, v1: 3 }));
});
it('must not match (3)', function () {
assert.isTrue(someFive([3, 5]));
assert.isFalse(someFive({}));
});

@@ -196,0 +238,0 @@ });

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