Make fp tests browser runnable.

This commit is contained in:
John-David Dalton
2015-12-05 23:36:02 -08:00
parent 769f78a2b7
commit 42c077de02
7 changed files with 1020 additions and 654 deletions

View File

@@ -53,6 +53,7 @@ script:
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || $BIN $OPTION ./test.js ../lodash.min.js"
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.js&noglobals=true\" tags=\"development\""
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.min.js&noglobals=true\" tags=\"production\""
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash-fp tests\" runner=\"test/fp.html?noglobals=true\" tags=\"development\""
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../lodash.js\" tags=\"development,underscore\""
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../lodash.min.js\" tags=\"production,underscore\""
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../lodash.js\" tags=\"development,backbone\""

92
dist/lodash.fp.js vendored
View File

@@ -86,14 +86,14 @@ return /******/ (function(modules) { // webpackBootstrap
* @returns {Function|Object} Returns the converted function or object.
*/
function baseConvert(util, name, func) {
if (!func) {
if (typeof func != 'function') {
func = name;
name = null;
name = undefined;
}
if (func == null) {
throw new TypeError;
}
var isLib = name == null && typeof func.VERSION == 'string';
var isLib = name === undefined && typeof func.VERSION == 'string';
var _ = isLib ? func : {
'ary': util.ary,
@@ -264,19 +264,26 @@ return /******/ (function(modules) { // webpackBootstrap
// Iterate over methods for the current ary cap.
var pairs = [];
each(mapping.caps, function(cap) {
each(mapping.aryMethodMap[cap], function(name) {
var func = _[mapping.keyMap[name] || name];
each(mapping.aryMethodMap[cap], function(key) {
var func = _[mapping.keyMap[key] || key];
if (func) {
// Wrap the lodash method and its aliases.
var wrapped = wrap(name, func);
pairs.push([name, wrapped]);
each(mapping.aliasMap[name] || [], function(alias) { pairs.push([alias, wrapped]); });
pairs.push([key, wrap(key, func)]);
}
});
});
// Assign to `_` leaving `_.prototype` unchanged to allow chaining.
each(pairs, function(pair) { _[pair[0]] = pair[1]; });
each(pairs, function(pair) {
_[pair[0]] = pair[1];
});
// Wrap the lodash method and its aliases.
each(keys(_), function(key) {
each(mapping.aliasMap[key] || [], function(alias) {
_[alias] = _[key];
});
});
return _;
}
@@ -291,9 +298,33 @@ return /******/ (function(modules) { // webpackBootstrap
/** Used to map method names to their aliases. */
'aliasMap': {
'ary': ['nAry'],
'conj': ['allPass'],
'disj': ['somePass'],
'filter': ['whereEq'],
'flatten': ['unnest'],
'flow': ['pipe'],
'flowRight': ['compose'],
'forEach': ['each'],
'forEachRight': ['eachRight'],
'head': ['first']
'get': ['path'],
'getOr': ['pathOr'],
'head': ['first'],
'includes': ['contains'],
'initial': ['init'],
'isEqual': ['equals'],
'mapValues': ['mapObj'],
'matchesProperty': ['pathEq'],
'modArgs': ['useWith'],
'modArgsSet': ['converge'],
'omit': ['dissoc', 'omitAll'],
'pick': ['pickAll'],
'property': ['prop'],
'propertyOf': ['propOf'],
'rest': ['unapply'],
'some': ['all'],
'spread': ['apply'],
'zipObject': ['zipObj']
},
/** Used to map method names to their iteratee ary. */
@@ -312,6 +343,7 @@ return /******/ (function(modules) { // webpackBootstrap
'findLast': 1,
'findLastIndex': 1,
'findLastKey': 1,
'flatMap': 1,
'forEach': 1,
'forEachRight': 1,
'forIn': 1,
@@ -338,24 +370,26 @@ return /******/ (function(modules) { // webpackBootstrap
/** Used to map ary to method names. */
'aryMethodMap': {
1: (
'attempt,ceil,create,curry,floor,iteratee,invert,memoize,method,methodOf,' +
'mixin,rest,reverse,round,runInContext,template,trim,trimLeft,trimRight,' +
'words,zipObject').split(','),
'attempt,ceil,create,curry,floor,fromPairs,iteratee,invert,over,overEvery,' +
'overSome,memoize,method,methodOf,mixin,rest,reverse,round,runInContext,template,' +
'trim,trimLeft,trimRight,uniqueId,words').split(','),
2: (
'ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,countBy,curryN,debounce,' +
'defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,' +
'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,' +
'debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,' +
'dropWhile,endsWith,every,extend,filter,find,find,findIndex,findKey,findLast,' +
'findLastIndex,findLastKey,forEach,forEachRight,forIn,forInRight,forOwn,' +
'forOwnRight,get,groupBy,includes,indexBy,indexOf,intersection,invoke,' +
'isMatch,lastIndexOf,map,mapKeys,mapValues,maxBy,minBy,merge,omit,pad,padLeft,' +
'padRight,parseInt,partition,pick,pull,pullAll,pullAt,random,range,rearg,reject,' +
'findLastIndex,findLastKey,flatMap,forEach,forEachRight,forIn,forInRight,' +
'forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,intersection,' +
'invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,matchesProperty,' +
'maxBy,mean,minBy,merge,modArgs,modArgsSet,omit,pad,padLeft,padRight,parseInt,' +
'partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,' +
'remove,repeat,result,sampleSize,set,some,sortBy,sortByOrder,sortedIndexBy,' +
'sortedLastIndexBy,sortedUniqBy,startsWith,sumBy,take,takeRight,takeRightWhile,' +
'takeWhile,throttle,times,trunc,union,uniqBy,uniqueId,without,wrap,xor,zip').split(','),
'sortedLastIndexBy,sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,' +
'takeRightWhile,takeWhile,throttle,times,truncate,union,uniqBy,without,wrap,' +
'xor,zip,zipObject').split(','),
3: (
'assignWith,clamp,differenceBy,extendWith,inRange,intersectionBy,isEqualWith,' +
'isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,reduceRight,slice,' +
'transform,unionBy,xorBy,zipWith').split(','),
'assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,' +
'isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,' +
'reduceRight,slice,transform,unionBy,xorBy,zipWith').split(','),
4:
['fill']
},
@@ -377,14 +411,13 @@ return /******/ (function(modules) { // webpackBootstrap
},
/** Used to iterate `mapping.aryMethodMap` keys. */
'caps': ['1', '2', '3', '4'],
'caps': [1, 2, 3, 4],
/** Used to map keys to other keys. */
'keyMap': {
'curryN': 'curry',
'curryRightN': 'curryRight',
'debounceOpt': 'debounce',
'throttleOpt': 'throttle'
'getOr': 'get'
},
/** Used to identify methods which mutate arrays or objects. */
@@ -413,8 +446,11 @@ return /******/ (function(modules) { // webpackBootstrap
/** Used to track methods that skip `_.rearg`. */
'skipReargMap': {
'difference': true,
'matchesProperty': true,
'random': true,
'range': true,
'rangeRight': true,
'zip': true,
'zipObject': true
}
};

File diff suppressed because one or more lines are too long

222
dist/mapping.fp.js vendored Normal file
View File

@@ -0,0 +1,222 @@
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["mapping"] = factory();
else
root["mapping"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports) {
module.exports = {
/** Used to map method names to their aliases. */
'aliasMap': {
'ary': ['nAry'],
'conj': ['allPass'],
'disj': ['somePass'],
'filter': ['whereEq'],
'flatten': ['unnest'],
'flow': ['pipe'],
'flowRight': ['compose'],
'forEach': ['each'],
'forEachRight': ['eachRight'],
'get': ['path'],
'getOr': ['pathOr'],
'head': ['first'],
'includes': ['contains'],
'initial': ['init'],
'isEqual': ['equals'],
'mapValues': ['mapObj'],
'matchesProperty': ['pathEq'],
'modArgs': ['useWith'],
'modArgsSet': ['converge'],
'omit': ['dissoc', 'omitAll'],
'pick': ['pickAll'],
'property': ['prop'],
'propertyOf': ['propOf'],
'rest': ['unapply'],
'some': ['all'],
'spread': ['apply'],
'zipObject': ['zipObj']
},
/** Used to map method names to their iteratee ary. */
'aryIterateeMap': {
'assignWith': 2,
'cloneDeepWith': 1,
'cloneWith': 1,
'dropRightWhile': 1,
'dropWhile': 1,
'every': 1,
'extendWith': 2,
'filter': 1,
'find': 1,
'findIndex': 1,
'findKey': 1,
'findLast': 1,
'findLastIndex': 1,
'findLastKey': 1,
'flatMap': 1,
'forEach': 1,
'forEachRight': 1,
'forIn': 1,
'forInRight': 1,
'forOwn': 1,
'forOwnRight': 1,
'isEqualWith': 2,
'isMatchWith': 2,
'map': 1,
'mapKeys': 1,
'mapValues': 1,
'partition': 1,
'reduce': 2,
'reduceRight': 2,
'reject': 1,
'remove': 1,
'some': 1,
'takeRightWhile': 1,
'takeWhile': 1,
'times': 1,
'transform': 2
},
/** Used to map ary to method names. */
'aryMethodMap': {
1: (
'attempt,ceil,create,curry,floor,fromPairs,iteratee,invert,over,overEvery,' +
'overSome,memoize,method,methodOf,mixin,rest,reverse,round,runInContext,template,' +
'trim,trimLeft,trimRight,uniqueId,words').split(','),
2: (
'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,' +
'debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,' +
'dropWhile,endsWith,every,extend,filter,find,find,findIndex,findKey,findLast,' +
'findLastIndex,findLastKey,flatMap,forEach,forEachRight,forIn,forInRight,' +
'forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,intersection,' +
'invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,matchesProperty,' +
'maxBy,mean,minBy,merge,modArgs,modArgsSet,omit,pad,padLeft,padRight,parseInt,' +
'partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,' +
'remove,repeat,result,sampleSize,set,some,sortBy,sortByOrder,sortedIndexBy,' +
'sortedLastIndexBy,sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,' +
'takeRightWhile,takeWhile,throttle,times,truncate,union,uniqBy,without,wrap,' +
'xor,zip,zipObject').split(','),
3: (
'assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,' +
'isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,' +
'reduceRight,slice,transform,unionBy,xorBy,zipWith').split(','),
4:
['fill']
},
/** Used to map ary to rearg configs by method ary. */
'aryReargMap': {
2: [1, 0],
3: [2, 1, 0],
4: [3, 2, 0, 1]
},
/** Used to map ary to rearg configs by method names. */
'methodReargMap': {
'clamp': [2, 0, 1],
'reduce': [2, 0, 1],
'reduceRight': [2, 0, 1],
'slice': [2, 0, 1],
'transform': [2, 0, 1]
},
/** Used to iterate `mapping.aryMethodMap` keys. */
'caps': [1, 2, 3, 4],
/** Used to map keys to other keys. */
'keyMap': {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get'
},
/** Used to identify methods which mutate arrays or objects. */
'mutateMap': {
'array': {
'fill': true,
'pull': true,
'pullAll': true,
'pullAllBy': true,
'pullAt': true,
'remove': true,
'reverse': true
},
'object': {
'assign': true,
'assignWith': true,
'defaults': true,
'defaultsDeep': true,
'extend': true,
'extendWith': true,
'merge': true,
'mergeWith': true
}
},
/** Used to track methods that skip `_.rearg`. */
'skipReargMap': {
'difference': true,
'matchesProperty': true,
'random': true,
'range': true,
'rangeRight': true,
'zip': true,
'zipObject': true
}
};
/***/ }
/******/ ])
});
;

View File

@@ -30,7 +30,7 @@ var mappingConfig = {
'entry': path.join(__dirname, 'mapping.js'),
'output': {
'path': distPath,
'filename': 'fp-mapping.js',
'filename': 'mapping.fp.js',
'library': 'mapping',
'libraryTarget': 'umd'
}

42
test/fp.html Normal file
View File

@@ -0,0 +1,42 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>lodash-fp Test Suite</title>
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
</head>
<body>
<script>
// Avoid reporting tests to Sauce Labs when script errors occur.
if (location.port == '9001') {
window.onerror = function(message) {
if (window.QUnit) {
QUnit.config.done.length = 0;
}
global_test_results = { 'message': message };
};
}
</script>
<script src="../lodash.js"></script>
<script src="../dist/lodash.fp.js"></script>
<script src="../dist/mapping.fp.js"></script>
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="../node_modules/qunit-extras/qunit-extras.js"></script>
<script src="../node_modules/platform/platform.js"></script>
<script src="./asset/test-ui.js"></script>
<script src="./test-fp.js"></script>
<div id="qunit"></div>
<script>
// Set a more readable browser name.
window.onload = function() {
var timeoutId = setInterval(function() {
var ua = document.getElementById('qunit-userAgent');
if (ua) {
ua.innerHTML = platform;
clearInterval(timeoutId);
}
}, 16);
};
</script>
</body>
</html>

File diff suppressed because it is too large Load Diff