npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lodash-mixins-collection

v1.1.0

Published

A little collection of additional mix-ins for great lodash library.

Downloads

2

Readme

lodash-mixins

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 ... ).

Installation

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

Array

_.in(value, array)

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

_.contains(array, value)

Alias for existing _.includes method.

_.contains([2,3,5,6], 6);
// produces true

Collection

_.renameKeys(collection, fromKey, toKey)

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}]

Lang

_.isDefined(variable)

This is the opposite of _.isUndefined.

var a = {b: 1};
_.isDefined(a.c);
// produces false

_.isNumeric(variable)

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

String

_.connect(...)

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

_.toSlug(string)

Transforms given string to slug.

_.toSlug('Today is a nice day');
// produces 'today-is-a-nice-day'

_.toUpperCase(string)

Just a wrapper of the original toString method.

_.toUpperCase('very simple');
// produces 'VERY SIMPLE'

_.words(sentence, count, ending)

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...'