Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
underscore-es
Advanced tools
__
/\ \ __
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
\ \____/
\/___/
Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects. It's available in ES6 and UMD (cjs, amd, iife) formats
ES6 & Beyond usage:
import _template from 'underscore-es/template';
var basicTemplate = _template("Ok, i use <%= builder %> for my es6 and beyond stuff !");
var result = basicTemplate({builder: 'rollup'});
console.log( result );
// => "Ok, i use rollup for my es6 and beyond stuff !"
nb: only _chain
isn't available in this case.
another way to use chaining feature here is through _compose
or _use
.
import _use from 'underscore-es/use';
import _initial from 'underscore-es/initial';
import _filter from 'underscore-es/filter';
import _union from 'underscore-es/union';
import _last from 'underscore-es/last';
function note (num) {return 'result: '+ (num + 10) + " / 20"}
var test = _use([1, 2, 3, 6, 9])
.do(_union, [1, 3, 11], [2, 6, 10, 14])
.do(_filter, (num) => num % 2 == 0)
.do(_initial)
.do(_last)
.do(note)
.value();
console.log( test );
// => result: 20 / 20
import features depending of their category
import * as $co from 'underscore-es/_collections';
import * as $ar from 'underscore-es/_arrays';
import * as $ob from 'underscore-es/_objects';
import * as $fu from 'underscore-es/_functions';
import * as $ut from 'underscore-es/_utilities';
console.log( $ar._union([4,7], [7,0,3]) );
// => [4, 7, 0, 3]
import _ from 'underscore-es'; // or from 'underscore-es/_namespace'
_.chain([4,7])
.union([7,0,3])
.initial()
.reverse()
.head()
.value()
// => 0
Since this underscore source code has been rewritten to be more es6 friendly :
the _.templateSettings
property is now _.template.settings
import _template from 'underscore-es/template';
_template.settings = {
evaluate: /\{\{([\s\S]+?)\}\}/g,
interpolate: /\{\{=([\s\S]+?)\}\}/g
};
var custom = _template('<ul>{{ for (var key in people) { }}<li>{{= people[key] }}</li>{{ } }}</ul>');
var result = custom({people: {moe: 'Moe', larry: 'Larry', curly: 'Curly'}});
console.log( result );
// => <ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>
the _.iteratee
shall now (for global importation) be overwritten through _.setIteratee([fn])
method
import _iteratee from './underscore-es/iteratee';
import _setIteratee from './underscore-es/iteratee';
import _countBy from './underscore-es/countBy';
import _isRegExp from './underscore-es/isRegExp';
import _filter from './underscore-es/filter';
_setIteratee( function(value) {
// RegEx values return a function that returns the number of matches
if (_isRegExp(value)) return function(obj) {
return (obj.match(value) || []).length;
};
return value;
});
// test some methods that claim to be transformed through `_iteratee`
var collection = ['foo', 'bar', 'bbiz'];
console.log(_countBy(collection, /b/g))
// => {0: 1, 1: 1, 2: 1}
console.log(_filter(collection, /b/g))
// => ['bar', 'bbiz']
Documentation is the place to find what you need to know !
This project adheres to a code of conduct. By participating, you are expected to uphold this code.
For support and questions, please use the gitter channel or stackoverflow
Underscore is an open-sourced component of DocumentCloud: https://github.com/documentcloud
Many thanks to our contributors: https://github.com/tnga/underscore-es/contributors https://github.com/jashkenas/underscore/contributors
FAQs
javaScript's functional programming helper library for ES6 and beyond.
The npm package underscore-es receives a total of 118 weekly downloads. As such, underscore-es popularity was classified as not popular.
We found that underscore-es demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.