Skip to content

Instantly share code, notes, and snippets.

@aledoroshenko
Last active October 16, 2016 08:13
Show Gist options
  • Save aledoroshenko/12116845a9daf3aa6a743889a36e6ede to your computer and use it in GitHub Desktop.
Save aledoroshenko/12116845a9daf3aa6a743889a36e6ede 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 path from 'path';
import expect from 'expect';
import _ from 'lodash';
var obj = {a: [], b: [1,2], c: [], d: [1]};
var filteredObj = _.pickBy(obj, function(val){
return val.length > 0;
});
var filteredObj2 = _.omitBy(obj, _.isEmpty);
expect(filteredObj).toEqual({b: [1,2], d: [1]})
expect(filteredObj2).toEqual({b: [1,2], d: [1]})
console.log(filteredObj2)
console.log('Tests passed');
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"expect": "1.20.2",
"lodash": "4.13.1",
"undefined": "v4.5.0"
}
}
'use strict';
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _expect = require('expect');
var _expect2 = _interopRequireDefault(_expect);
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var obj = { a: [], b: [1, 2], c: [], d: [1] };
var filteredObj = _lodash2.default.pickBy(obj, function (val) {
return val.length > 0;
});
var filteredObj2 = _lodash2.default.omitBy(obj, _lodash2.default.isEmpty);
(0, _expect2.default)(filteredObj).toEqual({ b: [1, 2], d: [1] });
(0, _expect2.default)(filteredObj2).toEqual({ b: [1, 2], d: [1] });
console.log(filteredObj2);
console.log('Tests passed');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment