Skip to content

Instantly share code, notes, and snippets.

@aledoroshenko
Last active November 2, 2016 13:15
Show Gist options
  • Save aledoroshenko/7815b693b64f1591b7bbe4d9693d20f0 to your computer and use it in GitHub Desktop.
Save aledoroshenko/7815b693b64f1591b7bbe4d9693d20f0 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
import _ from 'lodash';
import expect from 'expect';
const obj = [
{
name: 'test1',
colors: [
{name: 'red', code: '3'},
{name: 'green', code: '3'},
]
},
{
name: 'test2',
colors: [
{name: 'red', code: '3'},
{name: 'green', code: '3'},
]
},
{
name: 'test3',
colors: [
{name: 'yellow', code: '3'}
]
}
]
var a = _.filter(obj, {colors: [{name: 'red'}]});
console.log(a);
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"lodash": "4.16.4",
"expect": "1.20.2"
}
}
'use strict';
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
var _expect = require('expect');
var _expect2 = _interopRequireDefault(_expect);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var obj = [{
name: 'test1',
colors: [{ name: 'red', code: '3' }, { name: 'green', code: '3' }]
}, {
name: 'test2',
colors: [{ name: 'red', code: '3' }, { name: 'green', code: '3' }]
}, {
name: 'test3',
colors: [{ name: 'yellow', code: '3' }]
}];
var a = _lodash2.default.filter(obj, { colors: [{ name: 'red' }] });
console.log(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment