0.1.0 • Published 10 years ago

turbo-lodash v0.1.0

Weekly downloads
7
License
MIT
Repository
github
Last release
10 years ago

lodash-mixins

A set of mixins for lodash.

Mixins

_.getOrElse(obj, key, elseValue)

var user = {
	name: 'Frank'
};

_.getOrElse(user, 'name', 'John');

// -> Frank

_.getOrElse(user, 'age', 20);

// -> 20

_.mergeArrays(olds, news, key)

var olds = [{
	_id: 1,
	name: 'Milk'
}, {
	_id: 2,
	name: 'Eggs'
}];

var news = [{
	_id: 2,
	name: 'Meat'
}, {
	_id: 1,
	name: 'Hamburger'

}];

_.mergeArrays(olds, news, '_id');

// -> [{ _id: 1 name: 'Hamburger' }, { _id: 2, name: 'Meat' }]

_.isValidUrl(url)

var url = 'http://google.com';

_.isValidUrl(url);

// -> true

var url = 'http://google';

_.isValidUrl(url);

// -> false

_.isValidEmail(email)

var email = 'me@example.com';

_.isValidEmail(email);

// -> true

var email = 'me@me.t';

_.isValidEmail(email);

// -> false