
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
lodash-mixins-collection
Advanced tools
A little collection of additional mix-ins for great lodash library.
A little collection of additional mix-ins for great lodash
library (https://github.com/lodash/lodash). Here you can find quick docs of each mixin - they are organized the same way as in the original lodash
docs - alphabetically and by mixin category (string
, collection
, array
... ).
Install via bower using bower install lodash-mixins --save
or simply download and include lodash-mixins.min.js
. Be sure to initialize original lodash before registering these mix-ins. The only dependency to this package is lodash
itself. ES6 is not required.
NPM support added, you can download it via: npm i lodash-mixins-collection
Alias for existing _.includes
method. Added just to make code more readable in certain cases (notice that order of parameters is switched).
_.in(5, [2,3,5,6]);
// produces true
Alias for existing _.includes
method.
_.contains([2,3,5,6], 6);
// produces true
Loops over collection of objects and renames a key.
_.renameKeys([{a: 2, b:4}, {x: 3, b:3}], 'x', 'a')
// produces [{"a":2,"b":4},{"b":3,"a":3}]
This is the opposite of _.isUndefined
.
var a = {b: 1};
_.isDefined(a.c);
// produces false
Checks if given variable represents a numeric value.
_.isNumeric('12');
// produces true
_.isNumeric('12.5');
// produces true
_.isNumeric('12,5');
// produces false
_.isNumeric('dsa');
// produces false
Connects all arguments with given string. If one of the argument is an array, it will be considered as an array of values that need to be connected. You can pass any number of arguments, the last argument is the string that will connect everything.
If last argument is a string, then that will be used for connecting each part. Also, instead of a string, an object can be passed where you can set three parameters, these are the defaults:
{"main": "", "last": "", "strict": "false"}
If strict is set to false
(the default setting), then values like empty strings and null
will simply be skipped in the final output (examples below).
_.connect('Today', 'is', 'a cool', 'day', ' ');
// produces 'Today is a cool day.'
_.connect('Today', 'is', ['a cool', 'day'], '::');
// produces 'Today::is::a::cool::day.'
_.connect('One', ['two','three','four'], null, 'five', 'six', {main: ', ', last:' and ', strict: false})
// produces 'One, two, three, four, five and six'
_.connect('One', ['two','three','four'], null, 'five', 'six', {main: ', ', last:' and ', strict: true})
// produces 'One, two, three, four, null, five and six'
Additional _.connect helpers are also included:
_.spaced(...); // Connects arguments with a blank space " "
_.dashed(...); // Connects arguments with a dash "-"
_.dotted(...); // Connects arguments with a dot "."
_.slashed(...); // Connects arguments with a forward slash "/"
_.listed(...); // Connects all arguments with a comma, except last one for which 'and' word is used - useful when outputting lists in user interface
Transforms given string to slug.
_.toSlug('Today is a nice day');
// produces 'today-is-a-nice-day'
Just a wrapper of the original toString method.
_.toUpperCase('very simple');
// produces 'VERY SIMPLE'
Returns first N words from given sentence. Optionally, you can append an additional ending to the output ('...' by default).
_.words('testing this thing right now', 3);
// produces 'testing this thing...'
FAQs
A little collection of additional mix-ins for great lodash library.
We found that lodash-mixins-collection 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
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.