Commit 91fff57b authored by Arthur Verschaeve's avatar Arthur Verschaeve

Migrate `lavaca_require` example to `todomvc-app-css`

Ref gh-1110
parent c5ddf214
node_modules/todomvc-app-css/*
!node_modules/todomvc-app-css/index.css
node_modules/todomvc-common/*
!node_modules/todomvc-common/base.js
!node_modules/todomvc-common/base.css
node_modules/dustjs-helpers/**
!node_modules/dustjs-helpers/dist/dust-helpers.js
node_modules/dustjs-linkedin/**
!node_modules/dustjs-linkedin/dist/dust-full.js
node_modules/mout/**
!node_modules/mout/src/**
node_modules/requirejs/**
!node_modules/requirejs/require.js
{
"name": "todomvc-lavaca_require",
"version": "0.0.0",
"dependencies": {
"todomvc-common": "~0.3.0",
"requirejs": "~2.1.6",
"dustjs-linkedin": "~1.1.1",
"dustjs-linkedin-helpers": "~1.1.1",
"jquery": "~2.0.3",
"mout": "~0.7.1"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,7 +3,8 @@
<head>
<meta charset="utf-8">
<title>Lavaca • TodoMVC</title>
<link rel="stylesheet" href="bower_components/todomvc-common/base.css">
<link rel="stylesheet" href="node_modules/todomvc-common/base.css">
<link rel="stylesheet" href="node_modules/todomvc-app-css/index.css">
</head>
<body>
<section id="todoapp"></section>
......@@ -12,8 +13,8 @@
<p>Created by <a href="https://github.com/mutualmobile/" data-external>Mutual Mobile</a></p>
<p>Part of <a href="http://todomvc.com" data-external>TodoMVC</a></p>
</footer>
<script src="bower_components/todomvc-common/base.js"></script>
<script src="bower_components/requirejs/require.js"></script>
<script src="node_modules/todomvc-common/base.js"></script>
<script src="node_modules/requirejs/require.js"></script>
<script src="js/libs/lavaca.js"></script>
<script src="js/app/boot.js"></script>
</body>
......
require.config({
baseUrl: 'js',
paths: {
$: '../bower_components/jquery/jquery',
jquery: '../bower_components/jquery/jquery',
mout: '../bower_components/mout/src',
dust: '../bower_components/dustjs-linkedin/dist/dust-full-1.1.1',
'dust-helpers': '../bower_components/dustjs-linkedin-helpers/dist/dust-helpers-1.1.1',
$: '../node_modules/jquery/dist/jquery',
jquery: '../node_modules/jquery/dist/jquery',
mout: '../node_modules/mout/src',
dust: '../node_modules/dustjs-linkedin/dist/dust-full',
'dust-helpers': '../node_modules/dustjs-helpers/dist/dust-helpers',
rdust: 'libs/require-dust',
lavaca: 'Lavaca',
Lavaca: 'lavaca'
......@@ -28,4 +28,4 @@ require.config({
}
}
});
require(['app/app']);
\ No newline at end of file
require(['app/app']);
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
define(function(require){
//automatically generated, do not edit!
//run `node build` instead
return {
'append' : require('./array/append'),
'collect' : require('./array/collect'),
'combine' : require('./array/combine'),
'compact' : require('./array/compact'),
'contains' : require('./array/contains'),
'difference' : require('./array/difference'),
'every' : require('./array/every'),
'filter' : require('./array/filter'),
'find' : require('./array/find'),
'findIndex' : require('./array/findIndex'),
'flatten' : require('./array/flatten'),
'forEach' : require('./array/forEach'),
'indexOf' : require('./array/indexOf'),
'insert' : require('./array/insert'),
'intersection' : require('./array/intersection'),
'invoke' : require('./array/invoke'),
'join' : require('./array/join'),
'lastIndexOf' : require('./array/lastIndexOf'),
'map' : require('./array/map'),
'max' : require('./array/max'),
'min' : require('./array/min'),
'pick' : require('./array/pick'),
'pluck' : require('./array/pluck'),
'range' : require('./array/range'),
'reduce' : require('./array/reduce'),
'reduceRight' : require('./array/reduceRight'),
'reject' : require('./array/reject'),
'remove' : require('./array/remove'),
'removeAll' : require('./array/removeAll'),
'shuffle' : require('./array/shuffle'),
'some' : require('./array/some'),
'sort' : require('./array/sort'),
'split' : require('./array/split'),
'toLookup' : require('./array/toLookup'),
'union' : require('./array/union'),
'unique' : require('./array/unique'),
'xor' : require('./array/xor'),
'zip' : require('./array/zip')
};
});
define(function () {
/**
* Appends an array to the end of another.
* The first array will be modified.
*/
function append(arr1, arr2) {
if (arr2 == null) {
return arr1;
}
var pad = arr1.length,
i = -1,
len = arr2.length;
while (++i < len) {
arr1[pad + i] = arr2[i];
}
return arr1;
}
return append;
});
define(['./append', '../function/makeIterator_'], function (append, makeIterator) {
/**
* Maps the items in the array and concatenates the result arrays.
*/
function collect(arr, callback, thisObj){
callback = makeIterator(callback, thisObj);
var results = [];
if (arr == null) {
return results;
}
var i = -1, len = arr.length;
while (++i < len) {
var value = callback(arr[i], i, arr);
if (value != null) {
append(results, value);
}
}
return results;
}
return collect;
});
define(['./indexOf'], function (indexOf) {
/**
* Combines an array with all the items of another.
* Does not allow duplicates and is case and type sensitive.
*/
function combine(arr1, arr2) {
if (arr2 == null) {
return arr1;
}
var i = -1, len = arr2.length;
while (++i < len) {
if (indexOf(arr1, arr2[i]) === -1) {
arr1.push(arr2[i]);
}
}
return arr1;
}
return combine;
});
define(['./filter'], function (filter) {
/**
* Remove all null/undefined items from array.
*/
function compact(arr) {
return filter(arr, function(val){
return (val != null);
});
}
return compact;
});
define(['./indexOf'], function (indexOf) {
/**
* If array contains values.
*/
function contains(arr, val) {
return indexOf(arr, val) !== -1;
}
return contains;
});
define(['./unique', './filter', './some', './contains'], function (unique, filter, some, contains) {
/**
* Return a new Array with elements that aren't present in the other Arrays.
*/
function difference(arr) {
var arrs = Array.prototype.slice.call(arguments, 1),
result = filter(unique(arr), function(needle){
return !some(arrs, function(haystack){
return contains(haystack, needle);
});
});
return result;
}
return difference;
});
define(['../function/makeIterator_'], function (makeIterator) {
/**
* Array every
*/
function every(arr, callback, thisObj) {
callback = makeIterator(callback, thisObj);
var result = true;
if (arr == null) {
return result;
}
var i = -1, len = arr.length;
while (++i < len) {
// we iterate over sparse items since there is no way to make it
// work properly on IE 7-8. see #64
if (!callback(arr[i], i, arr) ) {
result = false;
break;
}
}
return result;
}
return every;
});
define(['../function/makeIterator_'], function (makeIterator) {
/**
* Array filter
*/
function filter(arr, callback, thisObj) {
callback = makeIterator(callback, thisObj);
var results = [];
if (arr == null) {
return results;
}
var i = -1, len = arr.length, value;
while (++i < len) {
value = arr[i];
if (callback(value, i, arr)) {
results.push(value);
}
}
return results;
}
return filter;
});
define(['./findIndex'], function (findIndex) {
/**
* Returns first item that matches criteria
*/
function find(arr, iterator, thisObj){
var idx = findIndex(arr, iterator, thisObj);
return idx >= 0? arr[idx] : void(0);
}
return find;
});
define(['../function/makeIterator_'], function (makeIterator) {
/**
* Returns the index of the first item that matches criteria
*/
function findIndex(arr, iterator, thisObj){
iterator = makeIterator(iterator, thisObj);
if (arr == null) {
return -1;
}
var i = -1, len = arr.length;
while (++i < len) {
if (iterator(arr[i], i, arr)) {
return i;
}
}
return -1;
}
return findIndex;
});
define(['../lang/isArray', './append'], function (isArray, append) {
/*
* Helper function to flatten to a destination array.
* Used to remove the need to create intermediate arrays while flattening.
*/
function flattenTo(arr, result, level) {
if (arr == null) {
return result;
} else if (level === 0) {
append(result, arr);
return result;
}
var value,
i = -1,
len = arr.length;
while (++i < len) {
value = arr[i];
if (isArray(value)) {
flattenTo(value, result, level - 1);
} else {
result.push(value);
}
}
return result;
}
/**
* Recursively flattens an array.
* A new array containing all the elements is returned.
* If `shallow` is true, it will only flatten one level.
*/
function flatten(arr, level) {
level = level == null? -1 : level;
return flattenTo(arr, [], level);
}
return flatten;
});
define(function () {
/**
* Array forEach
*/
function forEach(arr, callback, thisObj) {
if (arr == null) {
return;
}
var i = -1,
len = arr.length;
while (++i < len) {
// we iterate over sparse items since there is no way to make it
// work properly on IE 7-8. see #64
if ( callback.call(thisObj, arr[i], i, arr) === false ) {
break;
}
}
}
return forEach;
});
define(function () {
/**
* Array.indexOf
*/
function indexOf(arr, item, fromIndex) {
fromIndex = fromIndex || 0;
if (arr == null) {
return -1;
}
var len = arr.length,
i = fromIndex < 0 ? len + fromIndex : fromIndex;
while (i < len) {
// we iterate over sparse items since there is no way to make it
// work properly on IE 7-8. see #64
if (arr[i] === item) {
return i;
}
i++;
}
return -1;
}
return indexOf;
});
define(['./difference', '../lang/toArray'], function (difference, toArray) {
/**
* Insert item into array if not already present.
*/
function insert(arr, rest_items) {
var diff = difference(toArray(arguments).slice(1), arr);
if (diff.length) {
Array.prototype.push.apply(arr, diff);
}
return arr.length;
}
return insert;
});
define(['./unique', './filter', './every', './contains'], function (unique, filter, every, contains) {
/**
* Return a new Array with elements common to all Arrays.
* - based on underscore.js implementation
*/
function intersection(arr) {
var arrs = Array.prototype.slice.call(arguments, 1),
result = filter(unique(arr), function(needle){
return every(arrs, function(haystack){
return contains(haystack, needle);
});
});
return result;
}
return intersection;
});
define(function () {
/**
* Call `methodName` on each item of the array passing custom arguments if
* needed.
*/
function invoke(arr, methodName, var_args){
if (arr == null) {
return arr;
}
var args = Array.prototype.slice.call(arguments, 2);
var i = -1, len = arr.length, value;
while (++i < len) {
value = arr[i];
value[methodName].apply(value, args);
}
return arr;
}
return invoke;
});
define(['./filter'], function(filter) {
function isValidString(val) {
return (val != null && val !== '');
}
/**
* Joins strings with the specified separator inserted between each value.
* Null values and empty strings will be excluded.
*/
function join(items, separator) {
separator = separator || '';
return filter(items, isValidString).join(separator);
}
return join;
});
define(function () {
/**
* Array lastIndexOf
*/
function lastIndexOf(arr, item, fromIndex) {
if (arr == null) {
return -1;
}
var len = arr.length;
fromIndex = (fromIndex == null || fromIndex >= len)? len - 1 : fromIndex;
fromIndex = (fromIndex < 0)? len + fromIndex : fromIndex;
while (fromIndex >= 0) {
// we iterate over sparse items since there is no way to make it
// work properly on IE 7-8. see #64
if (arr[fromIndex] === item) {
return fromIndex;
}
fromIndex--;
}
return -1;
}
return lastIndexOf;
});
define(['../function/makeIterator_'], function (makeIterator) {
/**
* Array map
*/
function map(arr, callback, thisObj) {
callback = makeIterator(callback, thisObj);
var results = [];
if (arr == null){
return results;
}
var i = -1, len = arr.length;
while (++i < len) {
results[i] = callback(arr[i], i, arr);
}
return results;
}
return map;
});
define(['../function/makeIterator_'], function (makeIterator) {
/**
* Return maximum value inside array
*/
function max(arr, iterator, thisObj){
if (arr == null || !arr.length) {
return Infinity;
} else if (arr.length && !iterator) {
return Math.max.apply(Math, arr);
} else {
iterator = makeIterator(iterator, thisObj);
var result,
compare = -Infinity,
value,
temp;
var i = -1, len = arr.length;
while (++i < len) {
value = arr[i];
temp = iterator(value, i, arr);
if (temp > compare) {
compare = temp;
result = value;
}
}
return result;
}
}
return max;
});
define(['../function/makeIterator_'], function (makeIterator) {
/**
* Return minimum value inside array
*/
function min(arr, iterator, thisObj){
if (arr == null || !arr.length) {
return -Infinity;
} else if (arr.length && !iterator) {
return Math.min.apply(Math, arr);
} else {
iterator = makeIterator(iterator, thisObj);
var result,
compare = Infinity,
value,
temp;
var i = -1, len = arr.length;
while (++i < len) {
value = arr[i];
temp = iterator(value, i, arr);
if (temp < compare) {
compare = temp;
result = value;
}
}
return result;
}
}
return min;
});
define(['../random/randInt'], function (randInt) {
/**
* Remove random item(s) from the Array and return it.
* Returns an Array of items if [nItems] is provided or a single item if
* it isn't specified.
*/
function pick(arr, nItems){
if (nItems != null) {
var result = [];
if (nItems > 0 && arr && arr.length) {
nItems = nItems > arr.length? arr.length : nItems;
while (nItems--) {
result.push( pickOne(arr) );
}
}
return result;
}
return (arr && arr.length)? pickOne(arr) : void(0);
}
function pickOne(arr){
var idx = randInt(0, arr.length - 1);
return arr.splice(idx, 1)[0];
}
return pick;
});
define(['./map'], function (map) {
/**
* Extract a list of property values.
*/
function pluck(arr, propName){
return map(arr, propName);
}
return pluck;
});
define(['../math/countSteps'], function (countSteps) {
/**
* Returns an Array of numbers inside range.
*/
function range(start, stop, step) {
if (stop == null) {
stop = start;
start = 0;
}
step = step || 1;
var result = [],
nSteps = countSteps(stop - start, step),
i = start;
while (i <= stop) {
result.push(i);
i += step;
}
return result;
}
return range;
});
define(function () {
/**
* Array reduce
*/
function reduce(arr, fn, initVal) {
// check for args.length since initVal might be "undefined" see #gh-57
var hasInit = arguments.length > 2,
result = initVal;
if (arr == null || !arr.length) {
if (!hasInit) {
throw new Error('reduce of empty array with no initial value');
} else {
return initVal;
}
}
var i = -1, len = arr.length;
while (++i < len) {
if (!hasInit) {
result = arr[i];
hasInit = true;
} else {
result = fn(result, arr[i], i, arr);
}
}
return result;
}
return reduce;
});
define(function () {
/**
* Array reduceRight
*/
function reduceRight(arr, fn, initVal) {
// check for args.length since initVal might be "undefined" see #gh-57
var hasInit = arguments.length > 2;
if (arr == null || !arr.length) {
if (hasInit) {
return initVal;
} else {
throw new Error('reduce of empty array with no initial value');
}
}
var i = arr.length, result = initVal, value;
while (--i >= 0) {
// we iterate over sparse items since there is no way to make it
// work properly on IE 7-8. see #64
value = arr[i];
if (!hasInit) {
result = value;
hasInit = true;
} else {
result = fn(result, value, i, arr);
}
}
return result;
}
return reduceRight;
});
define(['../function/makeIterator_'], function(makeIterator) {
/**
* Array reject
*/
function reject(arr, callback, thisObj) {
callback = makeIterator(callback, thisObj);
var results = [];
if (arr == null) {
return results;
}
var i = -1, len = arr.length, value;
while (++i < len) {
value = arr[i];
if (!callback(value, i, arr)) {
results.push(value);
}
}
return results;
}
return reject;
});
define(['./indexOf'], function(indexOf){
/**
* Remove a single item from the array.
* (it won't remove duplicates, just a single item)
*/
function remove(arr, item){
var idx = indexOf(arr, item);
if (idx !== -1) arr.splice(idx, 1);
}
return remove;
});
define(['./indexOf'], function(indexOf){
/**
* Remove all instances of an item from array.
*/
function removeAll(arr, item){
var idx = indexOf(arr, item);
while (idx !== -1) {
arr.splice(idx, 1);
idx = indexOf(arr, item, idx);
}
}
return removeAll;
});
define(['../random/randInt'], function (randInt) {
/**
* Shuffle array items.
*/
function shuffle(arr) {
var results = [],
rnd;
if (arr == null) {
return results;
}
var i = -1, len = arr.length, value;
while (++i < len) {
if (!i) {
results[0] = arr[0];
} else {
rnd = randInt(0, i);
results[i] = results[rnd];
results[rnd] = arr[i];
}
}
return results;
}
return shuffle;
});
define(['../function/makeIterator_'], function (makeIterator) {
/**
* Array some
*/
function some(arr, callback, thisObj) {
callback = makeIterator(callback, thisObj);
var result = false;
if (arr == null) {
return result;
}
var i = -1, len = arr.length;
while (++i < len) {
// we iterate over sparse items since there is no way to make it
// work properly on IE 7-8. see #64
if ( callback(arr[i], i, arr) ) {
result = true;
break;
}
}
return result;
}
return some;
});
define(function () {
/**
* Merge sort (http://en.wikipedia.org/wiki/Merge_sort)
*/
function mergeSort(arr, compareFn) {
if (arr == null) {
return [];
} else if (arr.length < 2) {
return arr;
}
if (compareFn == null) {
compareFn = defaultCompare;
}
var mid, left, right;
mid = ~~(arr.length / 2);
left = mergeSort( arr.slice(0, mid), compareFn );
right = mergeSort( arr.slice(mid, arr.length), compareFn );
return merge(left, right, compareFn);
}
function defaultCompare(a, b) {
return a < b ? -1 : (a > b? 1 : 0);
}
function merge(left, right, compareFn) {
var result = [];
while (left.length && right.length) {
if (compareFn(left[0], right[0]) <= 0) {
// if 0 it should preserve same order (stable)
result.push(left.shift());
} else {
result.push(right.shift());
}
}
if (left.length) {
result.push.apply(result, left);
}
if (right.length) {
result.push.apply(result, right);
}
return result;
}
return mergeSort;
});
define(function() {
/**
* Split array into a fixed number of segments.
*/
function split(array, segments) {
segments = segments || 2;
var results = [];
if (array == null) {
return results;
}
var minLength = Math.floor(array.length / segments),
remainder = array.length % segments,
i = 0,
len = array.length,
segmentIndex = 0,
segmentLength;
while (i < len) {
segmentLength = minLength;
if (segmentIndex < remainder) {
segmentLength++;
}
results.push(array.slice(i, i + segmentLength));
segmentIndex++;
i += segmentLength;
}
return results;
}
return split;
});
define(['../lang/isFunction'], function (isFunction) {
/**
* Creates an object that holds a lookup for the objects in the array.
*/
function toLookup(arr, key) {
var result = {};
if (arr == null) {
return result;
}
var i = -1, len = arr.length, value;
if (isFunction(key)) {
while (++i < len) {
value = arr[i];
result[key(value)] = value;
}
} else {
while (++i < len) {
value = arr[i];
result[value[key]] = value;
}
}
return result;
}
return toLookup;
});
define(['./unique', './append'], function (unique, append) {
/**
* Concat multiple arrays and remove duplicates
*/
function union(arrs) {
var results = [];
var i = -1, len = arguments.length;
while (++i < len) {
append(results, arguments[i]);
}
return unique(results);
}
return union;
});
define(['./indexOf', './filter'], function(indexOf, filter){
/**
* @return {array} Array of unique items
*/
function unique(arr){
return filter(arr, isUnique);
}
function isUnique(item, i, arr){
return indexOf(arr, item, i+1) === -1;
}
return unique;
});
define(['./unique', './filter', './contains'], function (unique, filter, contains) {
/**
* Exclusive OR. Returns items that are present in a single array.
* - like ptyhon's `symmetric_difference`
*/
function xor(arr1, arr2) {
arr1 = unique(arr1);
arr2 = unique(arr2);
var a1 = filter(arr1, function(item){
return !contains(arr2, item);
}),
a2 = filter(arr2, function(item){
return !contains(arr1, item);
});
return a1.concat(a2);
}
return xor;
});
define(['./max', './map'], function (max, map) {
function getLength(arr) {
return arr == null ? 0 : arr.length;
}
/**
* Merges together the values of each of the arrays with the values at the
* corresponding position.
*/
function zip(arr){
var len = arr ? max(map(arguments, getLength)) : 0,
results = [],
i = -1;
while (++i < len) {
// jshint loopfunc: true
results.push(map(arguments, function(item) {
return item == null ? undefined : item[i];
}));
}
return results;
}
return zip;
});
define(function(require){
//automatically generated, do not edit!
//run `node build` instead
return {
'contains' : require('./collection/contains'),
'every' : require('./collection/every'),
'filter' : require('./collection/filter'),
'find' : require('./collection/find'),
'forEach' : require('./collection/forEach'),
'make_' : require('./collection/make_'),
'map' : require('./collection/map'),
'max' : require('./collection/max'),
'min' : require('./collection/min'),
'pluck' : require('./collection/pluck'),
'reduce' : require('./collection/reduce'),
'reject' : require('./collection/reject'),
'size' : require('./collection/size'),
'some' : require('./collection/some')
};
});
define(['./make_', '../array/contains', '../object/contains'], function (make, arrContains, objContains) {
/**
*/
return make(arrContains, objContains);
});
define(['./make_', '../array/every', '../object/every'], function (make, arrEvery, objEvery) {
/**
*/
return make(arrEvery, objEvery);
});
define(['./forEach', '../function/makeIterator_'], function (forEach, makeIterator) {
/**
* filter collection values, returns array.
*/
function filter(list, iterator, thisObj) {
iterator = makeIterator(iterator, thisObj);
var results = [];
if (!list) {
return results;
}
forEach(list, function(value, index, list) {
if (iterator(value, index, list)) {
results[results.length] = value;
}
});
return results;
}
return filter;
});
define(['./make_', '../array/find', '../object/find'], function(make, arrFind, objFind) {
/**
* Find value that returns true on iterator check.
*/
return make(arrFind, objFind);
});
define(['./make_', '../array/forEach', '../object/forOwn'], function (make, arrForEach, objForEach) {
/**
*/
return make(arrForEach, objForEach);
});
define(function(){
/**
* internal method used to create other collection modules.
*/
function makeCollectionMethod(arrMethod, objMethod, defaultReturn) {
return function(){
var args = Array.prototype.slice.call(arguments);
if (args[0] == null) {
return defaultReturn;
}
// array-like is treated as array
return (typeof args[0].length === 'number')? arrMethod.apply(null, args) : objMethod.apply(null, args);
};
}
return makeCollectionMethod;
});
define(['../lang/isObject', '../object/values', '../array/map', '../function/makeIterator_'], function (isObject, values, arrMap, makeIterator) {
/**
* Map collection values, returns Array.
*/
function map(list, callback, thisObj) {
callback = makeIterator(callback, thisObj);
// list.length to check array-like object, if not array-like
// we simply map all the object values
if( isObject(list) && list.length == null ){
list = values(list);
}
return arrMap(list, function (val, key, list) {
return callback(val, key, list);
});
}
return map;
});
define(['./make_', '../array/max', '../object/max'], function (make, arrMax, objMax) {
/**
* Get maximum value inside collection
*/
return make(arrMax, objMax);
});
define(['./make_', '../array/min', '../object/min'], function (make, arrMin, objMin) {
/**
* Get minimum value inside collection.
*/
return make(arrMin, objMin);
});
define(['./map'], function (map) {
/**
* Extract a list of property values.
*/
function pluck(list, key) {
return map(list, function(value) {
return value[key];
});
}
return pluck;
});
define(['./make_', '../array/reduce', '../object/reduce'], function (make, arrReduce, objReduce) {
/**
*/
return make(arrReduce, objReduce);
});
define(['./filter', '../function/makeIterator_'], function (filter, makeIterator) {
/**
* Inverse or collection/filter
*/
function reject(list, iterator, thisObj) {
iterator = makeIterator(iterator, thisObj);
return filter(list, function(value, index, list) {
return !iterator(value, index, list);
}, thisObj);
}
return reject;
});
define(['../lang/isArray', '../object/size'], function (isArray, objSize) {
/**
* Get collection size
*/
function size(list) {
if (!list) {
return 0;
}
if (isArray(list)) {
return list.length;
}
return objSize(list);
}
return size;
});
define(['./make_', '../array/some', '../object/some'], function (make, arrSome, objSome) {
/**
*/
return make(arrSome, objSome);
});
define(function(require){
//automatically generated, do not edit!
//run `node build` instead
return {
'dayOfTheYear' : require('./date/dayOfTheYear'),
'diff' : require('./date/diff'),
'i18n_' : require('./date/i18n_'),
'isLeapYear' : require('./date/isLeapYear'),
'isSame' : require('./date/isSame'),
'parseIso' : require('./date/parseIso'),
'startOf' : require('./date/startOf'),
'strftime' : require('./date/strftime'),
'timezoneAbbr' : require('./date/timezoneAbbr'),
'timezoneOffset' : require('./date/timezoneOffset'),
'totalDaysInMonth' : require('./date/totalDaysInMonth'),
'totalDaysInYear' : require('./date/totalDaysInYear'),
'weekOfTheYear' : require('./date/weekOfTheYear')
};
});
define(['../lang/isDate'], function (isDate) {
/**
* return the day of the year (1..366)
*/
function dayOfTheYear(date){
return (Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) -
Date.UTC(date.getFullYear(), 0, 1)) / 86400000 + 1;
}
return dayOfTheYear;
});
define(['./totalDaysInMonth', './totalDaysInYear', '../time/convert'], function(totalDaysInMonth, totalDaysInYear, convert){
/**
* calculate the difference between dates (range)
*/
function diff(start, end, unitName){
// sort the dates to make it easier to process (specially year/month)
if (start > end) {
var swap = start;
start = end;
end = swap;
}
var output;
if (unitName === 'month') {
output = getMonthsDiff(start, end);
} else if (unitName === 'year'){
output = getYearsDiff(start, end);
} else if (unitName != null) {
if (unitName === 'day') {
// ignore timezone difference because of daylight savings time
start = toUtc(start);
end = toUtc(end);
}
output = convert(end - start, 'ms', unitName);
} else {
output = end - start;
}
return output;
}
function toUtc(d){
// we ignore timezone differences on purpose because of daylight
// savings time, otherwise it would return fractional days/weeks even
// if a full day elapsed. eg:
// Wed Feb 12 2014 00:00:00 GMT-0200 (BRST)
// Sun Feb 16 2014 00:00:00 GMT-0300 (BRT)
// diff should be 4 days and not 4.041666666666667
return Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(),
d.getHours(), d.getMinutes(), d.getSeconds(),
d.getMilliseconds());
}
function getMonthsDiff(start, end){
return getElapsedMonths(start, end) +
getElapsedYears(start, end) * 12 +
getFractionalMonth(start, end);
}
function getYearsDiff(start, end){
var elapsedYears = getElapsedYears(start, end);
return elapsedYears + getFractionalYear(start, end, elapsedYears);
}
function getElapsedMonths(start, end){
var monthDiff = end.getMonth() - start.getMonth();
if (monthDiff < 0) {
monthDiff += 12;
}
// less than a full month
if (start.getDate() > end.getDate()) {
monthDiff -= 1;
}
return monthDiff;
}
function getElapsedYears(start, end){
var yearDiff = end.getFullYear() - start.getFullYear();
// less than a full year
if (start.getMonth() > end.getMonth()) {
yearDiff -= 1;
}
return yearDiff;
}
function getFractionalMonth(start, end){
var fractionalDiff = 0;
var startDay = start.getDate();
var endDay = end.getDate();
if (startDay !== endDay) {
var startTotalDays = totalDaysInMonth(start);
var endTotalDays = totalDaysInMonth(end);
var totalDays;
var daysElapsed;
if (startDay > endDay) {
// eg: Jan 29 - Feb 27 (29 days elapsed but not a full month)
var baseDay = startTotalDays - startDay;
daysElapsed = endDay + baseDay;
// total days should be relative to 1st day of next month if
// startDay > endTotalDays
totalDays = (startDay > endTotalDays)?
endTotalDays + baseDay + 1 : startDay + baseDay;
} else {
// fractional is only based on endMonth eg: Jan 12 - Feb 18
// (6 fractional days, 28 days until next full month)
daysElapsed = endDay - startDay;
totalDays = endTotalDays;
}
fractionalDiff = daysElapsed / totalDays;
}
return fractionalDiff;
}
function getFractionalYear(start, end, elapsedYears){
var base = elapsedYears?
new Date(end.getFullYear(), start.getMonth(), start.getDate()) :
start;
var elapsedDays = diff(base, end, 'day');
return elapsedDays / totalDaysInYear(end);
}
return diff;
});
define(function(){
// de-DE (German)
return {
"am" : "",
"pm" : "",
"x": "%d/%m/%y",
"X": "%H:%M:%S",
"c": "%a %d %b %Y %H:%M:%S %Z",
"months" : [
"Januar",
"Februar",
"März",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember"
],
"months_abbr" : [
"Jan",
"Febr",
"März",
"Apr",
"Mai",
"Juni",
"Juli",
"Aug",
"Sept",
"Okt",
"Nov",
"Dez"
],
"days" : [
"Sonntag",
"Montag",
"Dienstag",
"Mittwoch",
"Donnerstag",
"Freitag",
"Samstag"
],
"days_abbr" : [
"So",
"Mo",
"Di",
"Mi",
"Do",
"Fr",
"Sa"
]
};
});
define(function(){
// en-US (English, United States)
return {
"am" : "AM",
"pm" : "PM",
"x": "%m/%d/%y",
"X": "%H:%M:%S",
"c": "%a %d %b %Y %I:%M:%S %p %Z",
"months" : [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
"months_abbr" : [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
"days" : [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
"days_abbr" : [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
]
};
});
define(function(){
// pt-BR (Brazillian Portuguese)
return {
"am" : "",
"pm" : "",
"x": "%d/%m/%y",
"X": "%H:%M:%S",
"c": "%a %d %b %Y %H:%M:%S %Z",
"months" : [
"Janeiro",
"Fevereiro",
"Março",
"Abril",
"Maio",
"Junho",
"Julho",
"Agosto",
"Setembro",
"Outubro",
"Novembro",
"Dezembro"
],
"months_abbr" : [
"Jan",
"Fev",
"Mar",
"Abr",
"Mai",
"Jun",
"Jul",
"Ago",
"Set",
"Out",
"Nov",
"Dez"
],
"days" : [
"Domingo",
"Segunda",
"Terça",
"Quarta",
"Quinta",
"Sexta",
"Sábado"
],
"days_abbr" : [
"Dom",
"Seg",
"Ter",
"Qua",
"Qui",
"Sex",
"Sáb"
]
};
});
define(['../object/mixIn', './i18n/en-US'], function(mixIn, enUS){
// we also use mixIn to make sure we don't affect the original locale
var activeLocale = mixIn({}, enUS, {
// we expose a "set" method to allow overriding the global locale
set : function(localeData){
mixIn(activeLocale, localeData);
}
});
return activeLocale;
});
define(['../lang/isDate'], function (isDate) {
/**
* checks if it's a leap year
*/
function isLeapYear(fullYear){
if (isDate(fullYear)) {
fullYear = fullYear.getFullYear();
}
return fullYear % 400 === 0 || (fullYear % 100 !== 0 && fullYear % 4 === 0);
}
return isLeapYear;
});
define(['./startOf'], function (startOf) {
/**
* Check if date is "same" with optional period
*/
function isSame(date1, date2, period){
if (period) {
date1 = startOf(date1, period);
date2 = startOf(date2, period);
}
return Number(date1) === Number(date2);
}
return isSame;
});
define(['../array/some'], function (some) {
var datePatterns = [
/^([0-9]{4})$/, // YYYY
/^([0-9]{4})-([0-9]{2})$/, // YYYY-MM (YYYYMM not allowed)
/^([0-9]{4})-?([0-9]{2})-?([0-9]{2})$/ // YYYY-MM-DD or YYYYMMDD
];
var ORD_DATE = /^([0-9]{4})-?([0-9]{3})$/; // YYYY-DDD
var timePatterns = [
/^([0-9]{2}(?:\.[0-9]*)?)$/, // HH.hh
/^([0-9]{2}):?([0-9]{2}(?:\.[0-9]*)?)$/, // HH:MM.mm
/^([0-9]{2}):?([0-9]{2}):?([0-9]{2}(\.[0-9]*)?)$/ // HH:MM:SS.ss
];
var DATE_TIME = /^(.+)T(.+)$/;
var TIME_ZONE = /^(.+)([+\-])([0-9]{2}):?([0-9]{2})$/;
function matchAll(str, patterns) {
var match;
var found = some(patterns, function(pattern) {
return !!(match = pattern.exec(str));
});
return found ? match : null;
}
function getDate(year, month, day) {
var date = new Date(Date.UTC(year, month, day));
// Explicitly set year to avoid Date.UTC making dates < 100 relative to
// 1900
date.setUTCFullYear(year);
var valid =
date.getUTCFullYear() === year &&
date.getUTCMonth() === month &&
date.getUTCDate() === day;
return valid ? +date : NaN;
}
function parseOrdinalDate(str) {
var match = ORD_DATE.exec(str);
if (match ) {
var year = +match[1],
day = +match[2],
date = new Date(Date.UTC(year, 0, day));
if (date.getUTCFullYear() === year) {
return +date;
}
}
return NaN;
}
function parseDate(str) {
var match, year, month, day;
match = matchAll(str, datePatterns);
if (match === null) {
// Ordinal dates are verified differently.
return parseOrdinalDate(str);
}
year = (match[1] === void 0) ? 0 : +match[1];
month = (match[2] === void 0) ? 0 : +match[2] - 1;
day = (match[3] === void 0) ? 1 : +match[3];
return getDate(year, month, day);
}
function getTime(hr, min, sec) {
var valid =
(hr < 24 && hr >= 0 &&
min < 60 && min >= 0 &&
sec < 60 && min >= 0) ||
(hr === 24 && min === 0 && sec === 0);
if (!valid) {
return NaN;
}
return ((hr * 60 + min) * 60 + sec) * 1000;
}
function parseOffset(str) {
var match;
if (str.charAt(str.length - 1) === 'Z') {
str = str.substring(0, str.length - 1);
} else {
match = TIME_ZONE.exec(str);
if (match) {
var hours = +match[3],
minutes = (match[4] === void 0) ? 0 : +match[4],
offset = getTime(hours, minutes, 0);
if (match[2] === '-') {
offset *= -1;
}
return { offset: offset, time: match[1] };
}
}
// No time zone specified, assume UTC
return { offset: 0, time: str };
}
function parseTime(str) {
var match;
var offset = parseOffset(str);
str = offset.time;
offset = offset.offset;
if (isNaN(offset)) {
return NaN;
}
match = matchAll(str, timePatterns);
if (match === null) {
return NaN;
}
var hours = (match[1] === void 0) ? 0 : +match[1],
minutes = (match[2] === void 0) ? 0 : +match[2],
seconds = (match[3] === void 0) ? 0 : +match[3];
return getTime(hours, minutes, seconds) - offset;
}
/**
* Parse an ISO8601 formatted date string, and return a Date object.
*/
function parseISO8601(str){
var match = DATE_TIME.exec(str);
if (!match) {
// No time specified
return parseDate(str);
}
return parseDate(match[1]) + parseTime(match[2]);
}
return parseISO8601;
});
define(['../lang/clone'], function (clone) {
/**
* get a new Date object representing start of period
*/
function startOf(date, period){
date = clone(date);
// intentionally removed "break" from switch since start of
// month/year/etc should also reset the following periods
switch (period) {
case 'year':
date.setMonth(0);
/* falls through */
case 'month':
date.setDate(1);
/* falls through */
case 'week':
case 'day':
date.setHours(0);
/* falls through */
case 'hour':
date.setMinutes(0);
/* falls through */
case 'minute':
date.setSeconds(0);
/* falls through */
case 'second':
date.setMilliseconds(0);
break;
default:
throw new Error('"'+ period +'" is not a valid period');
}
// week is the only case that should reset the weekDay and maybe even
// overflow to previous month
if (period === 'week') {
var weekDay = date.getDay();
var baseDate = date.getDate();
if (weekDay) {
if (weekDay >= baseDate) {
//start of the week is on previous month
date.setDate(0);
}
date.setDate(date.getDate() - date.getDay());
}
}
return date;
}
return startOf;
});
define(['../number/pad', './i18n_', './dayOfTheYear', './timezoneOffset', './timezoneAbbr', './weekOfTheYear'], function (pad, i18n, dayOfTheYear, timezoneOffset, timezoneAbbr, weekOfTheYear) {
var _combinations = {
'D': '%m/%d/%y',
'F': '%Y-%m-%d',
'r': '%I:%M:%S %p',
'R': '%H:%M',
'T': '%H:%M:%S',
'x': 'locale',
'X': 'locale',
'c': 'locale'
};
/**
* format date based on strftime format
*/
function strftime(date, format, localeData){
localeData = localeData || i18n;
var reToken = /%([a-z%])/gi;
function makeIterator(fn) {
return function(match, token){
return fn(date, token, localeData);
};
}
return format
.replace(reToken, makeIterator(expandCombinations))
.replace(reToken, makeIterator(convertToken));
}
function expandCombinations(date, token, l10n){
if (token in _combinations) {
var expanded = _combinations[token];
return expanded === 'locale'? l10n[token] : expanded;
} else {
return '%'+ token;
}
}
function convertToken(date, token, l10n){
switch (token){
case 'a':
return l10n.days_abbr[date.getDay()];
case 'A':
return l10n.days[date.getDay()];
case 'h':
case 'b':
return l10n.months_abbr[date.getMonth()];
case 'B':
return l10n.months[date.getMonth()];
case 'C':
return pad(Math.floor(date.getFullYear() / 100), 2);
case 'd':
return pad(date.getDate(), 2);
case 'e':
return pad(date.getDate(), 2, ' ');
case 'H':
return pad(date.getHours(), 2);
case 'I':
return pad(date.getHours() % 12, 2);
case 'j':
return pad(dayOfTheYear(date), 3);
case 'L':
return pad(date.getMilliseconds(), 3);
case 'm':
return pad(date.getMonth() + 1, 2);
case 'M':
return pad(date.getMinutes(), 2);
case 'n':
return '\n';
case 'p':
return date.getHours() >= 12? l10n.pm : l10n.am;
case 'P':
return convertToken(date, 'p', l10n).toLowerCase();
case 's':
return date.getTime() / 1000;
case 'S':
return pad(date.getSeconds(), 2);
case 't':
return '\t';
case 'u':
var day = date.getDay();
return day === 0? 7 : day;
case 'U':
return pad(weekOfTheYear(date), 2);
case 'w':
return date.getDay();
case 'W':
return pad(weekOfTheYear(date, 1), 2);
case 'y':
return pad(date.getFullYear() % 100, 2);
case 'Y':
return pad(date.getFullYear(), 4);
case 'z':
return timezoneOffset(date);
case 'Z':
return timezoneAbbr(date);
case '%':
return '%';
default:
// keep unrecognized tokens
return '%'+ token;
}
}
return strftime;
});
define(['./timezoneOffset'], function(timezoneOffset) {
/**
* Abbreviated time zone name or similar information.
*/
function timezoneAbbr(date){
// Date.toString gives different results depending on the
// browser/system so we fallback to timezone offset
// chrome: 'Mon Apr 08 2013 09:02:04 GMT-0300 (BRT)'
// IE: 'Mon Apr 8 09:02:04 UTC-0300 2013'
var tz = /\(([A-Z]{3,4})\)/.exec(date.toString());
return tz? tz[1] : timezoneOffset(date);
}
return timezoneAbbr;
});
define(['../number/pad'], function (pad) {
/**
* time zone as hour and minute offset from UTC (e.g. +0900)
*/
function timezoneOffset(date){
var offset = date.getTimezoneOffset();
var abs = Math.abs(offset);
var h = pad(Math.floor(abs / 60), 2);
var m = pad(abs % 60, 2);
return (offset > 0? '-' : '+') + h + m;
}
return timezoneOffset;
});
define(['../lang/isDate', './isLeapYear'], function (isDate, isLeapYear) {
var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
/**
* returns the total amount of days in the month (considering leap years)
*/
function totalDaysInMonth(fullYear, monthIndex){
if (isDate(fullYear)) {
var date = fullYear;
year = date.getFullYear();
monthIndex = date.getMonth();
}
if (monthIndex === 1 && isLeapYear(fullYear)) {
return 29;
} else {
return DAYS_IN_MONTH[monthIndex];
}
}
return totalDaysInMonth;
});
define(['./isLeapYear'], function (isLeapYear) {
/**
* return the amount of days in the year following the gregorian calendar
* and leap years
*/
function totalDaysInYear(fullYear){
return isLeapYear(fullYear)? 366 : 365;
}
return totalDaysInYear;
});
define(['./dayOfTheYear'], function (dayOfTheYear) {
/**
* Return the week of the year based on given firstDayOfWeek
*/
function weekOfTheYear(date, firstDayOfWeek){
firstDayOfWeek = firstDayOfWeek == null? 0 : firstDayOfWeek;
var doy = dayOfTheYear(date);
var dow = (7 + date.getDay() - firstDayOfWeek) % 7;
var relativeWeekDay = 6 - firstDayOfWeek - dow;
return Math.floor((doy + relativeWeekDay) / 7);
}
return weekOfTheYear;
});
define(function(require){
//automatically generated, do not edit!
//run `node build` instead
return {
'bind' : require('./function/bind'),
'compose' : require('./function/compose'),
'debounce' : require('./function/debounce'),
'func' : require('./function/func'),
'makeIterator_' : require('./function/makeIterator_'),
'partial' : require('./function/partial'),
'prop' : require('./function/prop'),
'series' : require('./function/series'),
'throttle' : require('./function/throttle'),
'timeout' : require('./function/timeout'),
'times' : require('./function/times')
};
});
define(function(){
function slice(arr, offset){
return Array.prototype.slice.call(arr, offset || 0);
}
/**
* Return a function that will execute in the given context, optionally adding any additional supplied parameters to the beginning of the arguments collection.
* @param {Function} fn Function.
* @param {object} context Execution context.
* @param {rest} args Arguments (0...n arguments).
* @return {Function} Wrapped Function.
*/
function bind(fn, context, args){
var argsArr = slice(arguments, 2); //curried args
return function(){
return fn.apply(context, argsArr.concat(slice(arguments)));
};
}
return bind;
});
define(function () {
/**
* Returns a function that composes multiple functions, passing results to
* each other.
*/
function compose() {
var fns = arguments;
return function(arg){
// only cares about the first argument since the chain can only
// deal with a single return value anyway. It should start from
// the last fn.
var n = fns.length;
while (n--) {
arg = fns[n].call(this, arg);
}
return arg;
};
}
return compose;
});
define(function () {
/**
* Debounce callback execution
*/
function debounce(fn, threshold, isAsap){
var timeout, result;
function debounced(){
var args = arguments, context = this;
function delayed(){
if (! isAsap) {
result = fn.apply(context, args);
}
timeout = null;
}
if (timeout) {
clearTimeout(timeout);
} else if (isAsap) {
result = fn.apply(context, args);
}
timeout = setTimeout(delayed, threshold);
return result;
}
debounced.cancel = function(){
clearTimeout(timeout);
};
return debounced;
}
return debounce;
});
define(function () {
/**
* Returns a function that call a method on the passed object
*/
function func(name){
return function(obj){
return obj[name]();
};
}
return func;
});
......@@ -7,22 +7,19 @@ define(['./prop', '../object/deepMatches'], function(prop, deepMatches) {
*/
function makeIterator(src, thisObj){
switch(typeof src) {
case 'function':
// function is the first to improve perf (most common case)
return (typeof thisObj !== 'undefined')? function(val, i, arr){
return src.call(thisObj, val, i, arr);
} : src;
case 'object':
// typeof null == "object"
return (src != null)? function(val, key, target){
return (src != null)? function(val){
return deepMatches(val, src);
} : src;
case 'string':
case 'number':
return prop(src);
case 'function':
if (typeof thisObj === 'undefined') {
return src;
} else {
return function(val, i, arr){
return src.call(thisObj, val, i, arr);
};
}
default:
return src;
}
......
define(function () {
function slice(arr, offset){
return Array.prototype.slice.call(arr, offset || 0);
}
/**
* Creates a partially applied function.
*/
function partial(fn, var_args){
var argsArr = slice(arguments, 1); //curried args
return function(){
return fn.apply(this, argsArr.concat(slice(arguments)));
};
}
return partial;
});
define(function () {
/**
* Returns a function that will execute a list of functions in sequence
* passing the same arguments to each one. (useful for batch processing
* items during a forEach loop)
*/
function series(){
var fns = arguments;
return function(){
var i = 0,
n = fns.length;
while (i < n) {
fns[i].apply(this, arguments);
i += 1;
}
};
}
return series;
});
define(['../time/now'], function (now) {
/**
*/
function throttle(fn, delay){
var context, timeout, result, args,
cur, diff, prev = 0;
function delayed(){
prev = now();
timeout = null;
result = fn.apply(context, args);
}
function throttled(){
context = this;
args = arguments;
cur = now();
diff = delay - (cur - prev);
if (diff <= 0) {
clearTimeout(timeout);
prev = cur;
result = fn.apply(context, args);
} else if (! timeout) {
timeout = setTimeout(delayed, diff);
}
return result;
}
throttled.cancel = function(){
clearTimeout(timeout);
};
return throttled;
}
return throttle;
});
define(function () {
function slice(arr, offset){
return Array.prototype.slice.call(arr, offset || 0);
}
/**
* Delays the call of a function within a given context.
*/
function timeout(fn, millis, context){
var args = slice(arguments, 3);
return setTimeout(function() {
fn.apply(context, args);
}, millis);
}
return timeout;
});
define(function () {
/**
* Iterates over a callback a set amount of times
*/
function times(n, callback, thisObj){
var i = -1;
while (++i < n) {
if ( callback.call(thisObj, i) === false ) {
break;
}
}
}
return times;
});
/**@license
* mout v0.7.1 | http://moutjs.com | MIT license
*/
define(function(require){
//automatically generated, do not edit!
//run `node build` instead
return {
'VERSION' : '0.7.1',
'array' : require('./array'),
'collection' : require('./collection'),
'date' : require('./date'),
'function' : require('./function'),
'lang' : require('./lang'),
'math' : require('./math'),
'number' : require('./number'),
'object' : require('./object'),
'queryString' : require('./queryString'),
'random' : require('./random'),
'string' : require('./string'),
'time' : require('./time'),
'fn' : require('./function')
};
});
define(function(require){
//automatically generated, do not edit!
//run `node build` instead
return {
'clone' : require('./lang/clone'),
'createObject' : require('./lang/createObject'),
'ctorApply' : require('./lang/ctorApply'),
'deepClone' : require('./lang/deepClone'),
'defaults' : require('./lang/defaults'),
'inheritPrototype' : require('./lang/inheritPrototype'),
'is' : require('./lang/is'),
'isArguments' : require('./lang/isArguments'),
'isArray' : require('./lang/isArray'),
'isBoolean' : require('./lang/isBoolean'),
'isDate' : require('./lang/isDate'),
'isEmpty' : require('./lang/isEmpty'),
'isFinite' : require('./lang/isFinite'),
'isFunction' : require('./lang/isFunction'),
'isInteger' : require('./lang/isInteger'),
'isKind' : require('./lang/isKind'),
'isNaN' : require('./lang/isNaN'),
'isNull' : require('./lang/isNull'),
'isNumber' : require('./lang/isNumber'),
'isObject' : require('./lang/isObject'),
'isPlainObject' : require('./lang/isPlainObject'),
'isRegExp' : require('./lang/isRegExp'),
'isString' : require('./lang/isString'),
'isUndefined' : require('./lang/isUndefined'),
'isnt' : require('./lang/isnt'),
'kindOf' : require('./lang/kindOf'),
'toArray' : require('./lang/toArray'),
'toNumber' : require('./lang/toNumber'),
'toString' : require('./lang/toString')
};
});
define(['../object/mixIn'], function(mixIn){
/**
* Create Object using prototypal inheritance and setting custom properties.
* - Mix between Douglas Crockford Prototypal Inheritance <http://javascript.crockford.com/prototypal.html> and the EcmaScript 5 `Object.create()` method.
* @param {object} parent Parent Object.
* @param {object} [props] Object properties.
* @return {object} Created object.
*/
function createObject(parent, props){
function F(){}
F.prototype = parent;
return mixIn(new F(), props);
}
return createObject;
});
define(function () {
function F(){}
/**
* Do fn.apply on a constructor.
*/
function ctorApply(ctor, args) {
F.prototype = ctor.prototype;
var instance = new F();
ctor.apply(instance, args);
return instance;
}
return ctorApply;
});
......@@ -42,3 +42,4 @@ define(['./clone', '../object/forOwn', './kindOf', './isPlainObject'], function
return deepClone;
});
define(['./toArray', '../array/find'], function (toArray, find) {
/**
* Return first non void argument
*/
function defaults(var_args){
return find(toArray(arguments), nonVoid);
}
function nonVoid(val){
return val != null;
}
return defaults;
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment