Travis build: 1346
This commit is contained in:
@ -6,12 +6,10 @@ Use `Object.keys(source)` to get all the keys of the second object, then `Array.
|
||||
|
||||
```js
|
||||
const matches = (obj, source) =>
|
||||
Object.keys(source).every(
|
||||
key => obj.hasOwnProperty(key) && obj[key] === source[key]
|
||||
);
|
||||
Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]);
|
||||
```
|
||||
|
||||
```js
|
||||
matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true }) // true
|
||||
matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true }) // false
|
||||
matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true }); // true
|
||||
matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true }); // false
|
||||
```
|
||||
|
||||
@ -17,5 +17,9 @@ const matchesWith = (obj, source, fn) =>
|
||||
|
||||
```js
|
||||
const isGreeting = val => /^h(?:i|ello)$/.test(val);
|
||||
matchesWith({ greeting: 'hello' }, { greeting: 'hi' }, (oV, sV) => isGreeting(oV) && isGreeting(sV)); // true
|
||||
matchesWith(
|
||||
{ greeting: 'hello' },
|
||||
{ greeting: 'hi' },
|
||||
(oV, sV) => isGreeting(oV) && isGreeting(sV)
|
||||
); // true
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user