Comparing version 1.0.0 to 1.1.0
mout changelog | ||
============== | ||
v1.1.0 (2017/10/04) | ||
-------------------- | ||
- update dependencies | ||
- optimize `function/bind` | ||
- optimize `lang/kindOf` | ||
v0.12.0 (2016/03/03) | ||
@@ -5,0 +11,0 @@ -------------------- |
@@ -191,6 +191,6 @@ # array # | ||
// filter item that matches all properties/values pairs | ||
filter(arr, {name:'john', beard:false}); | ||
filter(users, {name:'john', beard:false}); | ||
// > [{name:'john', surnname:'connor', beard:false}] | ||
// items where 'beard' is a truthy value | ||
filter(arr, 'beard'); | ||
filter(users, 'beard'); | ||
// > [{name:'john', surnname:'doe', beard:true}] | ||
@@ -223,5 +223,5 @@ ``` | ||
// first item that matches all properties/values pairs | ||
find(arr, {name:'john'}); // {name:'john', surnname:'connor', beard:false} | ||
find(users, {name:'john'}); // {name:'john', surnname:'connor', beard:false} | ||
// first item where 'beard' is a truthy value | ||
find(arr, 'beard'); // {name:'john', surnname:'doe', beard:true} | ||
find(users, 'beard'); // {name:'john', surnname:'doe', beard:true} | ||
``` | ||
@@ -254,5 +254,5 @@ | ||
// last item that matches all properties/values pairs | ||
findLast(arr, {name:'john'}); // {name:'john', surnname:'doe', beard:true} | ||
findLast(users, {name:'john'}); // {name:'john', surnname:'doe', beard:true} | ||
// last item where 'beard' is a truthy value | ||
findLast(arr, 'beard'); // {name:'john', surnname:'doe', beard:true} | ||
findLast(users, 'beard'); // {name:'john', surnname:'doe', beard:true} | ||
``` | ||
@@ -259,0 +259,0 @@ |
function F(){} | ||
var bind = Function.prototype.bind; | ||
@@ -9,6 +9,4 @@ /** | ||
function ctorApply(ctor, args) { | ||
F.prototype = ctor.prototype; | ||
var instance = new F(); | ||
ctor.apply(instance, args); | ||
return instance; | ||
var Bound = bind.bind(ctor, undefined).apply(undefined, args); | ||
return new Bound(); | ||
} | ||
@@ -15,0 +13,0 @@ |
var _rKind = /^\[object (.*)\]$/, | ||
_toString = Object.prototype.toString, | ||
UNDEF; | ||
/** | ||
@@ -11,11 +6,5 @@ * Gets the "kind" of value. (e.g. "String", "Number", etc) | ||
function kindOf(val) { | ||
if (val === null) { | ||
return 'Null'; | ||
} else if (val === UNDEF) { | ||
return 'Undefined'; | ||
} else { | ||
return _rKind.exec( _toString.call(val) )[1]; | ||
} | ||
return Object.prototype.toString.call(val).slice(8, -1); | ||
} | ||
module.exports = kindOf; | ||
{ | ||
"name": "mout", | ||
"description": "Modular Utilities", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"homepage": "http://moutjs.com/", | ||
@@ -40,13 +40,13 @@ "author": "Miller Medeiros <contact@millermedeiros.com> (http://blog.millermedeiros.com)", | ||
"devDependencies": { | ||
"istanbul": "~0.1.27", | ||
"istanbul": "~0.4.5", | ||
"jasmine-node": "~1.14.5", | ||
"requirejs": "~2.2.0", | ||
"requirejs": "~2.3.5", | ||
"nodefy": "*", | ||
"mdoc": "~0.3.2", | ||
"mdoc": "~0.5.3", | ||
"handlebars": "~1.0.6", | ||
"commander": "~1.0.5", | ||
"rocambole": "~0.2.3", | ||
"commander": "~2.11.0", | ||
"rocambole": "~0.7.0", | ||
"jshint": "~2.9.1", | ||
"rimraf": "~2.5.2", | ||
"regenerate": "~0.5.4" | ||
"rimraf": "~2.6.2", | ||
"regenerate": "~1.3.3" | ||
}, | ||
@@ -53,0 +53,0 @@ "testling": { |
define(function () { | ||
function F(){} | ||
var bind = Function.prototype.bind; | ||
@@ -9,6 +9,4 @@ /** | ||
function ctorApply(ctor, args) { | ||
F.prototype = ctor.prototype; | ||
var instance = new F(); | ||
ctor.apply(instance, args); | ||
return instance; | ||
var Bound = bind.bind(ctor, undefined).apply(undefined, args); | ||
return new Bound(); | ||
} | ||
@@ -15,0 +13,0 @@ |
define(function () { | ||
var _rKind = /^\[object (.*)\]$/, | ||
_toString = Object.prototype.toString, | ||
UNDEF; | ||
/** | ||
@@ -11,11 +6,5 @@ * Gets the "kind" of value. (e.g. "String", "Number", etc) | ||
function kindOf(val) { | ||
if (val === null) { | ||
return 'Null'; | ||
} else if (val === UNDEF) { | ||
return 'Undefined'; | ||
} else { | ||
return _rKind.exec( _toString.call(val) )[1]; | ||
} | ||
return Object.prototype.toString.call(val).slice(8, -1); | ||
} | ||
return kindOf; | ||
}); |
@@ -9,9 +9,23 @@ define(['../lang/toString', './replaceAccents', './removeNonWord', './upperCase', './lowerCase'], function(toString, replaceAccents, removeNonWord, upperCase, lowerCase){ | ||
str = removeNonWord(str) | ||
.replace(/[\-_]/g, ' ') //convert all hyphens and underscores to spaces | ||
.replace(/\s[a-z]/g, upperCase) //convert first char of each word to UPPERCASE | ||
.replace(/\s+/g, '') //remove spaces | ||
.replace(/^[A-Z]/g, lowerCase); //convert first char to lowercase | ||
return str; | ||
.replace(/[\-_]/g, ' '); // convert all hyphens and underscores to spaces | ||
// handle acronyms | ||
// matches lowercase chars && uppercase words | ||
if (/[a-z]/.test(str) && /^|\s[A-Z]+\s|$/.test(str)) { | ||
// we convert any word that isn't all caps into lowercase | ||
str = str.replace(/\s(\w+)/g, function(word, m) { | ||
return /^[A-Z]+$/.test(m) ? word : lowerCase(word); | ||
}); | ||
} else if (/\s/.test(str)) { | ||
// if it doesn't contain an acronym and it has spaces we should | ||
// convert every word to lowercase | ||
str = lowerCase(str); | ||
} | ||
return str | ||
.replace(/\s[a-z]/g, upperCase) // convert first char of each word to UPPERCASE | ||
.replace(/^\s*[A-Z]+/g, lowerCase) // convert first word to lowercase | ||
.replace(/\s+/g, ''); // remove spaces | ||
} | ||
return camelCase; | ||
}); |
@@ -13,9 +13,23 @@ var toString = require('../lang/toString'); | ||
str = removeNonWord(str) | ||
.replace(/[\-_]/g, ' ') //convert all hyphens and underscores to spaces | ||
.replace(/\s[a-z]/g, upperCase) //convert first char of each word to UPPERCASE | ||
.replace(/\s+/g, '') //remove spaces | ||
.replace(/^[A-Z]/g, lowerCase); //convert first char to lowercase | ||
return str; | ||
.replace(/[\-_]/g, ' '); // convert all hyphens and underscores to spaces | ||
// handle acronyms | ||
// matches lowercase chars && uppercase words | ||
if (/[a-z]/.test(str) && /^|\s[A-Z]+\s|$/.test(str)) { | ||
// we convert any word that isn't all caps into lowercase | ||
str = str.replace(/\s(\w+)/g, function(word, m) { | ||
return /^[A-Z]+$/.test(m) ? word : lowerCase(word); | ||
}); | ||
} else if (/\s/.test(str)) { | ||
// if it doesn't contain an acronym and it has spaces we should | ||
// convert every word to lowercase | ||
str = lowerCase(str); | ||
} | ||
return str | ||
.replace(/\s[a-z]/g, upperCase) // convert first char of each word to UPPERCASE | ||
.replace(/^\s*[A-Z]+/g, lowerCase) // convert first word to lowercase | ||
.replace(/\s+/g, ''); // remove spaces | ||
} | ||
module.exports = camelCase; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
423677
552
9447