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

mout

Package Overview
Dependencies
Maintainers
4
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mout - npm Package Compare versions

Comparing version 0.9.1 to 0.10.0

array/equals.js

3

array.js

@@ -12,2 +12,3 @@

'difference' : require('./array/difference'),
'equals' : require('./array/equals'),
'every' : require('./array/every'),

@@ -21,2 +22,3 @@ 'filter' : require('./array/filter'),

'forEach' : require('./array/forEach'),
'groupBy' : require('./array/groupBy'),
'indexOf' : require('./array/indexOf'),

@@ -27,2 +29,3 @@ 'insert' : require('./array/insert'),

'join' : require('./array/join'),
'last' : require('./array/last'),
'lastIndexOf' : require('./array/lastIndexOf'),

@@ -29,0 +32,0 @@ 'map' : require('./array/map'),

2

array/findLastIndex.js

@@ -13,3 +13,3 @@ var makeIterator = require('../function/makeIterator_');

var n = arr.length;
while (n-- >= 0) {
while (--n >= 0) {
if (iterator(arr[n], n, arr)) {

@@ -16,0 +16,0 @@ return n;

mout changelog
==============
v0.10.0 (2014/09/02)
--------------------
- add `array/equals`;
- add `array/groupBy`;
- add `array/last`;
- add `function/wrap`;
- add `lang/GLOBAL`;
- add `lang/isPrimitive`;
- add `number/MAX_SAFE_INTEGER`;
- add `object/omit`;
- add `object/result`;
- add `object/result`;
- add `random/randString`;
- change `lang/isEmpty` behavior to return `true` for any value that isn't
a collection.
- fix `array/findLastIndex` to stop at zero index;
- improve `function/partial` to accept placeholders;
- improve `math.norm` behavior for values outside the range and for cases
where `val === min === max`;
- improve `object/get` behavior to return properties from any value that is
not `null` or `undefined`;
- move `object/deepEquals` to `lang/deepEquals` (improving the behavior);
v0.9.1 (2014/04/08)

@@ -5,0 +31,0 @@ -------------------

@@ -108,3 +108,25 @@ # array #

## equals(a, b, [compare]):Boolean
Checks if both arrays are equal.
```js
equals([1, 2], [1, 2]); // true
equals([2, 4], [1, 2]); // false
```
By default it uses the [lang/is](lang.html#is) as the `compare` function but
you can pass a custom function to change the behavior.
```js
function loose(a, b) {
return a == b;
}
equals(['1', 2], [1, 2], loose); // true
```
See: [object/equals](object.html#equals), [lang/deepEquals](lang.html#deepEquals)
## every(arr, callback, [thisObj]):Array

@@ -343,2 +365,17 @@

## groupBy(arr, [categorize=identity], [thisObj]):Object
Groups array elements by the `key` returned from the `categorize` function.
It will use the [function/identity](function.html#identity) as the default
`categorize` function.
```js
var items = ['lorem', 'ipsum', 'foo', 'bar', 'baz'];
groupBy(items, function(val) { return val.length });
// > {'3': ['foo', 'bar', 'baz'], '5': ['lorem', 'ipsum']}
```
## indexOf(arr, item, [fromIndex]):Number

@@ -419,3 +456,13 @@

## last(arr):*
Returns the last element of an array without modifying the array.
```js
last( [1, 2, 3, 4] ) // > 4
last( ['foo', 'bar'] ) // > 'bar'
```
## lastIndexOf(arr, item, [fromIndex]):Number

@@ -422,0 +469,0 @@

@@ -276,2 +276,16 @@ # function #

## wrap(fn, wrapper):Function
Wraps the first `fn` inside of the `wrapper` function, passing it as the first argument. This allows the `wrapper` to execute code before and after the `fn` runs, adjust the arguments, and execute it conditionally.
```js
var hello = function(name) { return "hello: " + name; };
hello = wrap(hello, function(func) {
return "before, " + func("moe") + ", after";
});
hello();
// output: 'before, hello: moe, after'
```
See: [`partial()`](#partial)
-------------------------------------------------------------------------------

@@ -278,0 +292,0 @@

@@ -122,2 +122,34 @@ # lang #

## deepEquals(a, b, [callback]):Boolean
Recursively tests whether two values contains the same keys and values.
`callback` specifies the equality comparison function used to compare
non-object values. It defaults to using the [`is()`](#is) function.
If the values are both an object or array, it will recurse into both values,
checking if their keys/values are equal. It will only check the keys and values
contained by the objects; it will not check the objects' prototypes. If either
of the values are not objects, they will be checked using the `callback`
function.
Example:
```js
deepEquals({ a: 1 }, { a: 1 }); // true
deepEquals({ value: { a: 1 } }, { value: { a: 1 } }); // true
deepEquals({ value: { a: 1 } }, { value: { a: 2 } }); // false
deepEquals({ value: { a: 1 } }, { value: { a: 1, b: 2 } }); // false
deepEquals({}, null); // false
deepEquals(null, null); // true
deepEquals(
{ a: { b: 1 } },
{ a: { b: '1' } },
function(a, b) { return a == b; }); // true
```
See: [object/equals](object.html#equals), [array/equals](array.html#equals)
## defaults(val, ...defaults):void

@@ -136,2 +168,9 @@

## GLOBAL:Object
Reference to the global context (`window` inside a browser, `global` on
node.js). Works on ES3 and ES5 strict-mode.
## inheritPrototype(childCtor, parentCtor):Object

@@ -239,2 +278,5 @@

Will return `true` for any object that doesn't contain enumerable properties
and also to any type of value that isn't considered a collection (boolean,
null, undefined, function, etc).

@@ -248,2 +290,7 @@ ```js

isEmpty({a:1, b:2}); // false
// null, undefined, booleans, numbers are considered as "empty" values
isEmpty(null); // true
isEmpty(undefined); // true
isEmpty(123); // true
isEmpty(true); // true
```

@@ -250,0 +297,0 @@

@@ -255,4 +255,9 @@ # math #

If `val < min` or `val > max` it will throw a `RangeError` since we can't
normalize the value.
norm(50, 0, 100); // 0.5
norm(75, 0, 100); // 0.75
norm(100, 0, 100); // 1
norm(-50, 0, 100); // RangeError: value (-50) must be between 0 and 100

@@ -259,0 +264,0 @@ ### Common use cases

@@ -98,2 +98,7 @@ # number #

## MAX_SAFE_INTEGER:Number
Maximum safe integer. `Math.pow(2,53) − 1`
## MAX_UINT:Number

@@ -100,0 +105,0 @@

@@ -54,33 +54,2 @@ # object #

## deepEquals(a, b, [callback]):Boolean
Recursively tests whether two objects contain the same keys and equal values.
`callback` specifies the equality comparison function used to compare
non-object values. It defaults to using the strict equals (`===`) operator.
If the values are both an object, it will recurse into the objects, checking if
their keys/values are equal. It will only check the keys and values contained
by the objects; it will not check the objects' prototypes. If the either of
the values are not objects, they will be checked using the `callback` function.
Example:
```js
deepEquals({ a: 1 }, { a: 1 }); // true
deepEquals({ value: { a: 1 } }, { value: { a: 1 } }); // true
deepEquals({ value: { a: 1 } }, { value: { a: 2 } }); // false
deepEquals({ value: { a: 1 } }, { value: { a: 1, b: 2 } }); // false
deepEquals({}, null); // false
deepEquals(null, null); // true
deepEquals(
{ a: { b: 1 } },
{ a: { b: '1' } },
function(a, b) { return a == b; }); // true
```
See: [`equals()`](#equals)
## deepFillIn(target, ...objects):Object

@@ -170,3 +139,3 @@

`callback` specifies the equality comparison function used to compare the
values. It defaults to using the strict equals (`===`) operator.
values. It defaults to using [lang/is](lang.html#is).

@@ -188,2 +157,3 @@ It will only check the keys and values contained by the objects; it will not

See: [array/equals](array.html#equals), [lang/deepEquals](lang.html#deepEquals)

@@ -605,3 +575,26 @@

## omit(obj, ...keys):Object
Return a copy of the object without the blacklisted keys.
See: [`filter()`](#filter)
```js
var user = {
firstName : 'John',
lastName : 'Doe',
dob : '1985/07/23',
gender : 'male'
};
// can pass an array of keys as second argument
var keys = ['firstName', 'dob']
omit(user, keys); // {lastName : 'Doe', gender : 'male'}
// or multiple arguments
omit(user, 'firstName', 'lastName'); // {dob : '1985/07/23', gender : 'male'}
```
## pick(obj, ...keys):Object

@@ -785,1 +778,21 @@

```
## result(object, property):Mixed
Evaluates an objects property and returns result.
```js
var person = {
name: 'john',
mood: function() {
// some dynamic calculated property.
return 'happy';
}
};
var name = result(person, 'name'), // john
mood = result(person, 'mood'); // happy
```

@@ -229,2 +229,25 @@ # random #

## randomString([length], [dictionary]):String
Returns a random string. By default returns string containing alphanumeric characters (lowercase and uppercase) with a length of 8.
### Arguments:
1. `[length]` (number) : Length of the string to return. Defaults to 8.
2. `[dictionary]` (string) : A string containing all characters used as a dictionary for the random string construction. Defaults to alphanumeric characters (lowercase and uppercase).
### Example:
```js
randString(); // returns a string with length 8.
randString(12); // returns a string of length 12.
randString(-1); // returns a string of length 8.
randString(null, 'pew!'); // returns a random string of length 8 composed of 'p', 'e', 'w' and '!'.
randString(10, '0'); // always returns '0's of length 10.
randString(rand(8, 10)); // returns a random string with length between 8 and 10.
```
-------------------------------------------------------------------------------

@@ -231,0 +254,0 @@

@@ -19,5 +19,6 @@

'timeout' : require('./function/timeout'),
'times' : require('./function/times')
'times' : require('./function/times'),
'wrap' : require('./function/wrap')
};

@@ -6,11 +6,19 @@ var slice = require('../array/slice');

*/
function partial(fn, var_args){
var argsArr = slice(arguments, 1); //curried args
return function(){
return fn.apply(this, argsArr.concat(slice(arguments)));
function partial(f) {
var as = slice(arguments, 1);
return function() {
var args = as.concat(slice(arguments));
for (var i = args.length; i--;) {
if (args[i] === partial._) {
args[i] = args.splice(-1)[0];
}
}
return f.apply(this, args);
};
}
partial._ = {};
module.exports = partial;
/**@license
* mout v0.9.1 | http://moutjs.com | MIT license
* mout v0.10.0 | http://moutjs.com | MIT license
*/

@@ -9,3 +9,3 @@

module.exports = {
'VERSION' : '0.9.1',
'VERSION' : '0.10.0',
'array' : require('./array'),

@@ -12,0 +12,0 @@ 'collection' : require('./collection'),

@@ -6,2 +6,3 @@

module.exports = {
'GLOBAL' : require('./lang/GLOBAL'),
'clone' : require('./lang/clone'),

@@ -11,2 +12,3 @@ 'createObject' : require('./lang/createObject'),

'deepClone' : require('./lang/deepClone'),
'deepEquals' : require('./lang/deepEquals'),
'defaults' : require('./lang/defaults'),

@@ -29,2 +31,3 @@ 'inheritPrototype' : require('./lang/inheritPrototype'),

'isPlainObject' : require('./lang/isPlainObject'),
'isPrimitive' : require('./lang/isPrimitive'),
'isRegExp' : require('./lang/isRegExp'),

@@ -31,0 +34,0 @@ 'isString' : require('./lang/isString'),

@@ -7,6 +7,6 @@ var forOwn = require('../object/forOwn');

// typeof null == 'object' so we check it first
return false;
return true;
} else if ( typeof val === 'string' || isArray(val) ) {
return !val.length;
} else if ( typeof val === 'object' || typeof val === 'function' ) {
} else if ( typeof val === 'object' ) {
var result = true;

@@ -19,3 +19,3 @@ forOwn(val, function(){

} else {
return false;
return true;
}

@@ -22,0 +22,0 @@ }

var isNumber = require('./isNumber');
var GLOBAL = require('./GLOBAL');
var global = this;
/**

@@ -11,6 +10,6 @@ * Check if value is finite

if (typeof val === 'string' && val !== '') {
is = global.isFinite( parseFloat(val) );
is = GLOBAL.isFinite( parseFloat(val) );
} else if (isNumber(val)){
// need to use isNumber because of Number constructor
is = global.isFinite( val );
is = GLOBAL.isFinite( val );
}

@@ -17,0 +16,0 @@ return is;

var kindOf = require('./kindOf');
var GLOBAL = require('./GLOBAL');
var _win = this;
/**

@@ -14,3 +13,3 @@ * Convert array-like object into array

if (val != null) {
if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === _win ) {
if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === GLOBAL ) {
//string, regexp, function have .length but user probably just want

@@ -17,0 +16,0 @@ //to wrap value into an array..

@@ -6,5 +6,9 @@

function norm(val, min, max){
return (val - min) / (max - min);
if (val < min || val > max) {
throw new RangeError('value (' + val + ') must be between ' + min + ' and ' + max);
}
return val === max ? 1 : (val - min) / (max - min);
}
module.exports = norm;

@@ -7,2 +7,3 @@

'MAX_INT' : require('./number/MAX_INT'),
'MAX_SAFE_INTEGER' : require('./number/MAX_SAFE_INTEGER'),
'MAX_UINT' : require('./number/MAX_UINT'),

@@ -9,0 +10,0 @@ 'MIN_INT' : require('./number/MIN_INT'),

@@ -8,3 +8,2 @@

'contains' : require('./object/contains'),
'deepEquals' : require('./object/deepEquals'),
'deepFillIn' : require('./object/deepFillIn'),

@@ -32,2 +31,3 @@ 'deepMatches' : require('./object/deepMatches'),

'namespace' : require('./object/namespace'),
'omit' : require('./object/omit'),
'pick' : require('./object/pick'),

@@ -37,2 +37,3 @@ 'pluck' : require('./object/pluck'),

'reject' : require('./object/reject'),
'result' : require('./object/result'),
'set' : require('./object/set'),

@@ -39,0 +40,0 @@ 'size' : require('./object/size'),

var hasOwn = require('./hasOwn');
var every = require('./every');
var isObject = require('../lang/isObject');
var is = require('../lang/is');
function defaultCompare(a, b) {
return a === b;
}
// Makes a function to compare the object values from the specified compare

@@ -25,3 +22,3 @@ // operation callback.

function equals(a, b, callback) {
callback = callback || defaultCompare;
callback = callback || is;

@@ -28,0 +25,0 @@ if (!isObject(a) || !isObject(b)) {

@@ -0,3 +1,3 @@

var isPrimitive = require('../lang/isPrimitive');
/**

@@ -12,3 +12,3 @@ * get "nested" object property

obj = obj[prop];
if (typeof obj !== 'object' || !obj) return;
if (obj == null) return;
}

@@ -15,0 +15,0 @@

{
"name": "mout",
"description": "Modular Utilities",
"version": "0.9.1",
"version": "0.10.0",
"homepage": "http://moutjs.com/",

@@ -6,0 +6,0 @@ "contributors": [

@@ -14,2 +14,3 @@

'randSign' : require('./random/randSign'),
'randString' : require('./random/randString'),
'random' : require('./random/random')

@@ -16,0 +17,0 @@ };

@@ -5,3 +5,3 @@ ![mout](http://moutjs.com/logo.png "Modular JavaScript Utilties")

[![Build Status](https://travis-ci.org/mout/mout.png?branch=master)](https://travis-ci.org/mout/mout)
[![Build Status](https://travis-ci.org/mout/mout.svg?branch=master)](https://travis-ci.org/mout/mout)

@@ -8,0 +8,0 @@ All code is library agnostic and consist mostly of helper methods that aren't

@@ -12,2 +12,3 @@ define(function(require){

'difference' : require('./array/difference'),
'equals' : require('./array/equals'),
'every' : require('./array/every'),

@@ -21,2 +22,3 @@ 'filter' : require('./array/filter'),

'forEach' : require('./array/forEach'),
'groupBy' : require('./array/groupBy'),
'indexOf' : require('./array/indexOf'),

@@ -27,2 +29,3 @@ 'insert' : require('./array/insert'),

'join' : require('./array/join'),
'last' : require('./array/last'),
'lastIndexOf' : require('./array/lastIndexOf'),

@@ -29,0 +32,0 @@ 'map' : require('./array/map'),

@@ -13,3 +13,3 @@ define(['../function/makeIterator_'], function (makeIterator) {

var n = arr.length;
while (n-- >= 0) {
while (--n >= 0) {
if (iterator(arr[n], n, arr)) {

@@ -16,0 +16,0 @@ return n;

@@ -19,5 +19,6 @@ define(function(require){

'timeout' : require('./function/timeout'),
'times' : require('./function/times')
'times' : require('./function/times'),
'wrap' : require('./function/wrap')
};
});

@@ -6,11 +6,19 @@ define(['../array/slice'], function (slice) {

*/
function partial(fn, var_args){
var argsArr = slice(arguments, 1); //curried args
return function(){
return fn.apply(this, argsArr.concat(slice(arguments)));
function partial(f) {
var as = slice(arguments, 1);
return function() {
var args = as.concat(slice(arguments));
for (var i = args.length; i--;) {
if (args[i] === partial._) {
args[i] = args.splice(-1)[0];
}
}
return f.apply(this, args);
};
}
partial._ = {};
return partial;
});
/**@license
* mout v0.9.1 | http://moutjs.com | MIT license
* mout v0.10.0 | http://moutjs.com | MIT license
*/

@@ -9,3 +9,3 @@ define(function(require){

return {
'VERSION' : '0.9.1',
'VERSION' : '0.10.0',
'array' : require('./array'),

@@ -12,0 +12,0 @@ 'collection' : require('./collection'),

@@ -6,2 +6,3 @@ define(function(require){

return {
'GLOBAL' : require('./lang/GLOBAL'),
'clone' : require('./lang/clone'),

@@ -11,2 +12,3 @@ 'createObject' : require('./lang/createObject'),

'deepClone' : require('./lang/deepClone'),
'deepEquals' : require('./lang/deepEquals'),
'defaults' : require('./lang/defaults'),

@@ -29,2 +31,3 @@ 'inheritPrototype' : require('./lang/inheritPrototype'),

'isPlainObject' : require('./lang/isPlainObject'),
'isPrimitive' : require('./lang/isPrimitive'),
'isRegExp' : require('./lang/isRegExp'),

@@ -31,0 +34,0 @@ 'isString' : require('./lang/isString'),

@@ -6,6 +6,6 @@ define(['../object/forOwn', './isArray'], function (forOwn, isArray) {

// typeof null == 'object' so we check it first
return false;
return true;
} else if ( typeof val === 'string' || isArray(val) ) {
return !val.length;
} else if ( typeof val === 'object' || typeof val === 'function' ) {
} else if ( typeof val === 'object' ) {
var result = true;

@@ -18,3 +18,3 @@ forOwn(val, function(){

} else {
return false;
return true;
}

@@ -21,0 +21,0 @@ }

@@ -1,5 +0,3 @@

define(['./isNumber'], function (isNumber) {
define(['./isNumber', './GLOBAL'], function (isNumber, GLOBAL) {
var global = this;
/**

@@ -11,6 +9,6 @@ * Check if value is finite

if (typeof val === 'string' && val !== '') {
is = global.isFinite( parseFloat(val) );
is = GLOBAL.isFinite( parseFloat(val) );
} else if (isNumber(val)){
// need to use isNumber because of Number constructor
is = global.isFinite( val );
is = GLOBAL.isFinite( val );
}

@@ -17,0 +15,0 @@ return is;

@@ -1,5 +0,3 @@

define(['./kindOf'], function (kindOf) {
define(['./kindOf', './GLOBAL'], function (kindOf, GLOBAL) {
var _win = this;
/**

@@ -14,3 +12,3 @@ * Convert array-like object into array

if (val != null) {
if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === _win ) {
if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === GLOBAL ) {
//string, regexp, function have .length but user probably just want

@@ -17,0 +15,0 @@ //to wrap value into an array..

@@ -6,5 +6,9 @@ define(function(){

function norm(val, min, max){
return (val - min) / (max - min);
if (val < min || val > max) {
throw new RangeError('value (' + val + ') must be between ' + min + ' and ' + max);
}
return val === max ? 1 : (val - min) / (max - min);
}
return norm;
});

@@ -7,2 +7,3 @@ define(function(require){

'MAX_INT' : require('./number/MAX_INT'),
'MAX_SAFE_INTEGER' : require('./number/MAX_SAFE_INTEGER'),
'MAX_UINT' : require('./number/MAX_UINT'),

@@ -9,0 +10,0 @@ 'MIN_INT' : require('./number/MIN_INT'),

@@ -8,3 +8,2 @@ define(function(require){

'contains' : require('./object/contains'),
'deepEquals' : require('./object/deepEquals'),
'deepFillIn' : require('./object/deepFillIn'),

@@ -32,2 +31,3 @@ 'deepMatches' : require('./object/deepMatches'),

'namespace' : require('./object/namespace'),
'omit' : require('./object/omit'),
'pick' : require('./object/pick'),

@@ -37,2 +37,3 @@ 'pluck' : require('./object/pluck'),

'reject' : require('./object/reject'),
'result' : require('./object/result'),
'set' : require('./object/set'),

@@ -39,0 +40,0 @@ 'size' : require('./object/size'),

@@ -1,7 +0,3 @@

define(['./hasOwn', './every', '../lang/isObject'], function(hasOwn, every, isObject) {
define(['./hasOwn', './every', '../lang/isObject', '../lang/is'], function(hasOwn, every, isObject, is) {
function defaultCompare(a, b) {
return a === b;
}
// Makes a function to compare the object values from the specified compare

@@ -23,3 +19,3 @@ // operation callback.

function equals(a, b, callback) {
callback = callback || defaultCompare;
callback = callback || is;

@@ -26,0 +22,0 @@ if (!isObject(a) || !isObject(b)) {

@@ -1,2 +0,2 @@

define(function () {
define(['../lang/isPrimitive'], function (isPrimitive) {

@@ -12,3 +12,3 @@ /**

obj = obj[prop];
if (typeof obj !== 'object' || !obj) return;
if (obj == null) return;
}

@@ -15,0 +15,0 @@

@@ -14,2 +14,3 @@ define(function(require){

'randSign' : require('./random/randSign'),
'randString' : require('./random/randString'),
'random' : require('./random/random')

@@ -16,0 +17,0 @@ };

Sorry, the diff of this file is not supported yet

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