Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash-contrib

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash-contrib - npm Package Compare versions

Comparing version 241.2.1 to 241.3.0

.travis.yml

10

_.util.strings.js

@@ -65,2 +65,12 @@ // lodash-contrib (lodash.util.strings.js 0.0.1)

return regexCandidate.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
},
humanize: function (slugish) {
return slugish
// insert a space between lower & upper
.replace(/([a-z])([A-Z])/g, '$1 $2')
// space before last upper in a sequence followed by lower
.replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3')
// uppercase the first character
.replace(/^./, function(str){ return str.toUpperCase(); });
}

@@ -67,0 +77,0 @@

2

CONTRIBUTING.md

@@ -5,3 +5,3 @@ ## How to contribute to lodash-contrib

* Before sending a pull request for a feature, be sure to have [tests like found in lodash](http://underscore.org/test/). Tests may be run in a browser by opening `test/index.html`. Tests and linting can be run in the terminal by using the `grunt test` command, or `grunt watch:test` to automatically rerun after file save.
* Before sending a pull request for a feature, be sure to have [tests like found in lodash](http://lodashjs.org/test/). Tests may be run in a browser by opening `test/index.html`. Tests and linting can be run in the terminal by using the `grunt test` command, or `grunt watch:test` to automatically rerun after file save.

@@ -8,0 +8,0 @@ * Use the same coding [style as lodash](https://github.com/documentcloud/lodash/blob/master/lodash.js).

@@ -0,0 +0,0 @@ // lodash-contrib v241.2.0

@@ -0,0 +0,0 @@ // lodash-contrib v241.2.0

@@ -5,9 +5,97 @@ ### object.builders

Documentation should use [Journo](https://github.com/jashkenas/journo) formats and standards.
--------------------------------------------------------------------------------
merge: function(/* objs */){
renameKeys: function(obj, kobj) {
snapshot: function(obj) {
updatePath: function(obj, fun, ks) {
setPath: function(obj, value, ks) {
frequencies: curry2(_.countBy)(_.identity)
#### frequencies
**Signature:** `_.frequencies(arr:Array)`
Returns an object whose property keys are the values of `arr`'s elements. The
property values are a count of how many times that value appeared in `arr`.
```javascript
var citations = ["Plato", "Aristotle", "Plotinus", "Plato"];
_.frequencies(citations);
// => { Plato: 2, Aristotle: 1, Plotinus: 1 }
```
--------------------------------------------------------------------------------
#### merge
**Signature:** `_.merge(obj1:Object[, obj:Object...])`
Merges two or more objects starting with the left-most and applying the keys
rightward.
```javascript
_.merge({ a: "alpha" }, { b: "beta" });
// => { a: "alpha", b: "beta" }
```
--------------------------------------------------------------------------------
#### renameKeys
**Signature:** `_.renameKeys(obj:Object, keyMap:Object)`
Takes an object (`obj`) and a map of keys (`keyMap`) and returns a new object
where the keys of `obj` have been renamed as specified in `keyMap`.
```javascript
_.renameKeys({ a: 1, b: 2 }, { a: "alpha", b: "beta" });
// => { alpha: 1, beta: 2 }
```
--------------------------------------------------------------------------------
#### setPath
**Signature:** `_.setPath(obj:Object, value:Any, ks:Array, defaultValue:Any)`
Sets the value of a property at any depth in `obj` based on the path described
by the `ks` array. If any of the properties in the `ks` path don't exist, they
will be created with `defaultValue`.
```javascript
_.setPath({}, "Plotinus", ["Platonism", "Neoplatonism"], {});
// => { Platonism: { Neoplatonism: "Plotinus" } }
```
--------------------------------------------------------------------------------
#### snapshot
**Signature:** `_.snapshot(obj:Object)`
Snapshots/clones an object deeply.
```javascript
var schools = { plato: "Academy", aristotle: "Lyceum" };
_.snapshot(schools);
// => { plato: "Academy", aristotle: "Lyceum" }
schools === _.snapshot(schools);
// => false
```
--------------------------------------------------------------------------------
**Signature:** `_.updatePath(obj:Object, fun:Function, ks:Array, defaultValue:Any)`
Updates the value at any depth in a nested object based on the path described by
the `ks` array. The function `fun` is called with the current value and is
expected to return a replacement value. If no keys are provided, then the
object itself is presented to `fun`. If a property in the path is missing, then
it will be created with `defaultValue`.
```javascript
var imperialize = function (val) {
if (val == "Republic) return "Empire";
else return val;
};
_.updatePath({ rome: "Republic" }, imperialize, ["rome"]);
// => { rome: "Empire" }
```

@@ -5,11 +5,181 @@ ### object.selectors

Documentation should use [Journo](https://github.com/jashkenas/journo) formats and standards.
--------------------------------------------------------------------------------
accessor: function(field) {
dictionary: function (obj) {
selectKeys: function (obj, ks) {
kv: function(obj, key) {
getPath: function getPath (obj, ks) {
hasPath: function hasPath (obj, ks) {
pickWhen: function(obj, pred) {
omitWhen: function(obj, pred) {
#### accessor
**Signature:** `_.accessor(field:String)`
Returns a function that will attempt to look up a named field in any object
that it is given.
```javascript
var getName = _.accessor('name');
getName({ name: 'Seneca' });
// => 'Seneca'
```
--------------------------------------------------------------------------------
#### dictionary
**Signature:** `_.dictionary(obj:Object)`
Given an object, returns a function that will attempt to look up a field that
it is given.
```javascript
var generals = {
rome: "Scipio",
carthage: "Hannibal"
};
var getGeneralOf = _.dictionary(generals);
_.getGeneralOf("rome");
// => "Scipio"
```
--------------------------------------------------------------------------------
#### getPath
**Signature:** `_.getPath(obj:Object, ks:String|Array)`
Gets the value at any depth in a nested object based on the path described by
the keys given. Keys may be given as an array or as a dot-separated string.
Returns `undefined` if the path cannot be reached.
```javascript
var countries = {
greece: {
athens: {
playwright: "Sophocles"
}
}
}
};
_.getPath(countries, "greece.athens.playwright");
// => "Sophocles"
_.getPath(countries, "greece.sparta.playwright");
// => undefined
_.getPath(countries, ["greece", "athens", "playwright"]);
// => "Sophocles"
_.getPath(countries, ["greece", "sparta", "playwright"]);
// => undefined
```
--------------------------------------------------------------------------------
#### hasPath
**Signature:** `_.hasPath(obj:Object, ks:String|Array)`
Returns a boolean indicating whether there is a property at the path described
by the keys given. Keys may be given as an array or as a dot-separated string.
```javascript
var countries = {
greece: {
athens: {
playwright: "Sophocles"
}
}
}
};
_.hasPath(countries, "greece.athens.playwright");
// => true
_.hasPath(countries, "greece.sparta.playwright");
// => false
_.hasPath(countries, ["greece", "athens", "playwright"]);
// => true
_.hasPath(countries, ["greece", "sparta", "playwright"]);
// => false
```
--------------------------------------------------------------------------------
#### kv
**Signature:** `_.kv(obj:Object, key:String)`
Returns the key/value pair for a given property in an object, undefined if not found.
```javascript
var playAuthor = {
"Medea": "Aeschylus"
};
_.kv(playAuthor, "Medea");
// => ["Medea", "Aeschylus"]
_.kv(playAuthor, "Hamlet");
// => undefined
```
--------------------------------------------------------------------------------
#### omitWhen
**Signature:** `_.omitWhen(obj, pred:Function)`
Returns a copy of `obj` omitting any properties that the predicate (`pred`)
function returns `true` for. The predicat function is invoked with each
property value, like so: `pred(propValue)`.
```javascript
var playwrights = {
euripedes: "Greece",
shakespere: "England"
};
_.omitWhen(obj, function (country) { return country == "England" });
// => { euripedes: "Greece" }
```
--------------------------------------------------------------------------------
#### pickWhen
**Signature:** `_.pickWhen(obj:Object, pred:Function)`
Returns a copy of `obj` containing only properties that the predicate (`pred`)
function returns `true` for. The predicate function is invoked with each
property value, like so: `pred(propValue)`.
```javascript
var playwrights = {
euripedes: "Greece",
shakespere: "England"
};
_.omitWhen(obj, function (country) { return country == "England" });
// => { shakespeare: "England" }
```
--------------------------------------------------------------------------------
#### selectKeys
**Signature:** `_.selectKeys(obj:Object, ks:Array);
Returns a copy of `obj` containing only the properties listed in the `ks` array.
```javascript
var philosopherCities = {
Philo: "Alexandria",
Plato: "Athens",
Plotinus: "Rome"
}
_.selectKeys(philosopherCities, ["Plato", "Plotinus"]);
// => { Plato: "Athens", Plotinus: "Rome" }
```
{
"name": "lodash-contrib",
"version": "241.2.1",
"version": "241.3.0",
"main": "index.js",
"dependencies": {
"lodash": "2.4.1"
},
"devDependencies": {
"lodash": "~2.4.1",
"grunt": "~0.4.1",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-uglify": "0.2.0",
"grunt-contrib-qunit": "~0.2.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-jshint": "~0.6.4",
"grunt-docco": "~0.3.0",
"grunt-tocdoc": "~0.1.0"
"grunt": "",
"grunt-contrib-concat": "",
"grunt-contrib-uglify": "",
"grunt-contrib-qunit": "",
"grunt-contrib-watch": "",
"grunt-contrib-jshint": "",
"grunt-docco": "",
"grunt-tocdoc": "",
"grunt-cli": ""
},

@@ -33,3 +36,6 @@ "repository": {

],
"scripts": {
"test": "node ./node_modules/grunt-cli/bin/grunt test"
},
"homepage": "https://github.com/Empeeric/lodash-contrib"
}

@@ -0,13 +1,13 @@

This is basically a [`lodash`](http://lodash.com/) compatible fork of [`underscore-contrib`](https://github.com/documentcloud/underscore-contrib)
lodash-contrib
==================
==============
[![Build Status](https://travis-ci.org/Empeeric/lodash-contrib.png?branch=master)](https://travis-ci.org/Empeeric/lodash-contrib)
The brass buckles on lodash's utility belt -- a contributors' library for [lodash](http://lodashjs.org/).
Links
-----
* [Documentation](http://documentcloud.github.io/lodash-contrib/)
* [Source repository](https://github.com/documentcloud/lodash-contrib)
* [Tickets and bug reports](https://github.com/documentcloud/lodash-contrib/issues?state=open)
* [Maintainer's website](http://www.fogus.me)
* [Documentation](http://empeeric.github.io/lodash-contrib/)
* [Source repository](https://github.com/Empeeric/lodash-contrib)
* [Tickets and bug reports](https://github.com/Empeeric/lodash-contrib/issues?state=open)

@@ -42,3 +42,3 @@ Why lodash-contrib?

There is still a lot of work to do around perf, documentation, examples, testing and distribution so any help
in those areas is welcomed. Pull requests are accepted, but please search the [issues](https://github.com/documentcloud/lodash-contrib/issues)
in those areas is welcomed. Pull requests are accepted, but please search the [issues](https://github.com/empeeric/lodash-contrib/issues)
before proposing a new sub-contrib or addition. Additionally, all patches and proposals should have strong

@@ -45,0 +45,0 @@ documentation, motivating cases and tests. It would be nice if we could not only provide useful tools built on

@@ -37,2 +37,13 @@

});
test('humanize', function() {
equal(_.humanize("lowercase"), "Lowercase");
equal(_.humanize("Class"), "Class");
equal(_.humanize("MyClass"), "My Class");
equal(_.humanize("HTML"), "HTML");
equal(_.humanize("PDFLoader"), "PDF Loader");
equal(_.humanize("AString"), "A String");
equal(_.humanize("SimpleXMLParser"), "Simple XML Parser");
equal(_.humanize("LastUpdateDateInt"), "Last Update Date Int");
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc