diff --git a/README.md b/README.md index 18c338e8087b..a4fe2b185143 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,6 @@ core.setImmediate(core.log, 42); // => 42 - [Dict](#dict) - [Partial application](#partial-application) - [Date formatting](#date-formatting) - - [Array](#array) - [Number](#number) - [Escaping characters](#escaping-characters) - [delay](#delay) @@ -1036,7 +1035,6 @@ Module `core.dict`. Based on [TC39 discuss](https://github.com/rwaldron/tc39-not .keyOf(object, var) -> key .includes(object, var) -> bool .reduce(object, fn(memo, val, key, @), memo?) -> var - .turn(object, fn(memo, val, key, @), memo = new @) -> memo ``` `Dict` create object without prototype from iterable or simple object. [Example](http://goo.gl/pnp8Vr): ```javascript @@ -1102,7 +1100,7 @@ Dict.set(O, '__proto__', {w: 2}); O['__proto__']; // => {w: 2} O['w']; // => undefined ``` -Other methods of `Dict` module are static equialents of `Array.prototype` methods for dictionaries, [examples](http://goo.gl/yARYXR): +Other methods of `Dict` module are static equialents of `Array.prototype` methods for dictionaries, [examples](http://goo.gl/xFi1RH): ```javascript var dict = {a: 1, b: 2, c: 3}; @@ -1157,13 +1155,6 @@ Dict.reduce(dict, function(memo, it){ Dict.reduce(dict, function(memo, it){ return memo + it; }, ''); // => '123' - -Dict.turn(dict, function(memo, it, key){ - memo[key + key] = it; -}); // => {aa: 1, bb: 2, cc: 3} -Dict.turn(dict, function(memo, it, key){ - it % 2 && memo.push(key + it); -}, []); // => ['a1', 'c3'] ``` ### Partial application Module `core.function.part`. @@ -1234,23 +1225,6 @@ new Date().format('M Y'); // => 'Ноябрь 2014' months: 'Январ:я|ь,Феврал:я|ь,Март:а|,Апрел:я|ь,Ма:я|й,Июн:я|ь,Июл:я|ь,Август:а|,Сентябр:я|ь,Октябр:я|ь,Ноябр:я|ь,Декабр:я|ь' }); ``` -### Array -Module `core.array.turn`. -```javascript -Array - #turn(fn(memo, val, index, @), memo = []) -> memo -``` -Method `Array#turn` reduce array to object, [example](http://goo.gl/zZbvq7): -```javascript -[1, 2, 3, 4, 5].turn(function(memo, it){ - memo['key' + it] = !!(it % 2); -}, {}); // => {key1: true, key2: false, key3: true, key4: false, key5: true} - -[1, 2, 3, 4, 5, 6, 7, 8, 9].turn(function(memo, it){ - it % 2 && memo.push(it * it); - if(memo.length == 3)return false; -}); // => [1, 9, 25] -``` ### Number Modules `core.number.iterator`. ```javascript diff --git a/build/build.ls b/build/build.ls index 9245c2e6fbc1..ce6e1dbaf49a 100644 --- a/build/build.ls +++ b/build/build.ls @@ -55,7 +55,6 @@ list = <[ core.delay core.function.part core.object - core.array.turn core.number.iterator core.string.escape-html core.date diff --git a/build/index.js b/build/index.js index ef47d34d9fae..364c9a6f0b43 100644 --- a/build/index.js +++ b/build/index.js @@ -4,7 +4,7 @@ banner = require('./config').banner; ref$ = require('fs'), readFile = ref$.readFile, writeFile = ref$.writeFile, unlink = ref$.unlink; webpack = require('webpack'); - list = ['es5', 'es6.symbol', 'es6.object.assign', 'es6.object.is', 'es6.object.set-prototype-of', 'es6.object.to-string', 'es6.object.statics-accept-primitives', 'es6.function.name', 'es6.function.has-instance', 'es6.number.constructor', 'es6.number.statics', 'es6.math', 'es6.string.from-code-point', 'es6.string.raw', 'es6.string.iterator', 'es6.string.code-point-at', 'es6.string.ends-with', 'es6.string.includes', 'es6.string.repeat', 'es6.string.starts-with', 'es6.array.from', 'es6.array.of', 'es6.array.iterator', 'es6.array.species', 'es6.array.copy-within', 'es6.array.fill', 'es6.array.find', 'es6.array.find-index', 'es6.regexp', 'es6.promise', 'es6.map', 'es6.set', 'es6.weak-map', 'es6.weak-set', 'es6.reflect', 'es7.array.includes', 'es7.string.at', 'es7.string.lpad', 'es7.string.rpad', 'es7.regexp.escape', 'es7.object.get-own-property-descriptors', 'es7.object.to-array', 'es7.map.to-json', 'es7.set.to-json', 'es7.observable', 'web.immediate', 'web.dom.iterable', 'web.timers', 'core.dict', 'core.iter-helpers', 'core.$for', 'core.delay', 'core.function.part', 'core.object', 'core.array.turn', 'core.number.iterator', 'core.string.escape-html', 'core.date', 'core.global', 'core.log', 'js.array.statics']; + list = ['es5', 'es6.symbol', 'es6.object.assign', 'es6.object.is', 'es6.object.set-prototype-of', 'es6.object.to-string', 'es6.object.statics-accept-primitives', 'es6.function.name', 'es6.function.has-instance', 'es6.number.constructor', 'es6.number.statics', 'es6.math', 'es6.string.from-code-point', 'es6.string.raw', 'es6.string.iterator', 'es6.string.code-point-at', 'es6.string.ends-with', 'es6.string.includes', 'es6.string.repeat', 'es6.string.starts-with', 'es6.array.from', 'es6.array.of', 'es6.array.iterator', 'es6.array.species', 'es6.array.copy-within', 'es6.array.fill', 'es6.array.find', 'es6.array.find-index', 'es6.regexp', 'es6.promise', 'es6.map', 'es6.set', 'es6.weak-map', 'es6.weak-set', 'es6.reflect', 'es7.array.includes', 'es7.string.at', 'es7.string.lpad', 'es7.string.rpad', 'es7.regexp.escape', 'es7.object.get-own-property-descriptors', 'es7.object.to-array', 'es7.map.to-json', 'es7.set.to-json', 'es7.observable', 'web.immediate', 'web.dom.iterable', 'web.timers', 'core.dict', 'core.iter-helpers', 'core.$for', 'core.delay', 'core.function.part', 'core.object', 'core.number.iterator', 'core.string.escape-html', 'core.date', 'core.global', 'core.log', 'js.array.statics']; experimental = ['es7.observable']; libraryBlacklist = ['es6.object.to-string', 'es6.function.name', 'es6.regexp', 'es6.number.constructor']; module.exports = function(arg$, next){ diff --git a/core/index.js b/core/index.js index 60898f6d99cb..3a4e557bffe5 100644 --- a/core/index.js +++ b/core/index.js @@ -4,7 +4,6 @@ require('../modules/core.$for'); require('../modules/core.delay'); require('../modules/core.function.part'); require('../modules/core.object'); -require('../modules/core.array.turn'); require('../modules/core.number.iterator'); require('../modules/core.string.escape-html'); require('../modules/core.date'); diff --git a/fn/array/index.js b/fn/array/index.js index 6a92ab31ef72..06d045d28397 100644 --- a/fn/array/index.js +++ b/fn/array/index.js @@ -9,5 +9,4 @@ require('../../modules/es6.array.find'); require('../../modules/es6.array.find-index'); require('../../modules/es7.array.includes'); require('../../modules/js.array.statics'); -require('../../modules/core.array.turn'); module.exports = require('../../modules/$').core.Array; \ No newline at end of file diff --git a/index.js b/index.js index 6b1cdb915a84..6338ce986223 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,6 @@ require('./modules/core.$for'); require('./modules/core.delay'); require('./modules/core.function.part'); require('./modules/core.object'); -require('./modules/core.array.turn'); require('./modules/core.number.iterator'); require('./modules/core.string.escape-html'); require('./modules/core.date'); diff --git a/library/core/index.js b/library/core/index.js index 60898f6d99cb..3a4e557bffe5 100644 --- a/library/core/index.js +++ b/library/core/index.js @@ -4,7 +4,6 @@ require('../modules/core.$for'); require('../modules/core.delay'); require('../modules/core.function.part'); require('../modules/core.object'); -require('../modules/core.array.turn'); require('../modules/core.number.iterator'); require('../modules/core.string.escape-html'); require('../modules/core.date'); diff --git a/library/fn/array/index.js b/library/fn/array/index.js index 6a92ab31ef72..06d045d28397 100644 --- a/library/fn/array/index.js +++ b/library/fn/array/index.js @@ -9,5 +9,4 @@ require('../../modules/es6.array.find'); require('../../modules/es6.array.find-index'); require('../../modules/es7.array.includes'); require('../../modules/js.array.statics'); -require('../../modules/core.array.turn'); module.exports = require('../../modules/$').core.Array; \ No newline at end of file diff --git a/library/index.js b/library/index.js index 6b1cdb915a84..6338ce986223 100644 --- a/library/index.js +++ b/library/index.js @@ -5,7 +5,6 @@ require('./modules/core.$for'); require('./modules/core.delay'); require('./modules/core.function.part'); require('./modules/core.object'); -require('./modules/core.array.turn'); require('./modules/core.number.iterator'); require('./modules/core.string.escape-html'); require('./modules/core.date'); diff --git a/library/modules/core.dict.js b/library/modules/core.dict.js index 78c6519fde66..9546ebe169d7 100644 --- a/library/modules/core.dict.js +++ b/library/modules/core.dict.js @@ -10,7 +10,8 @@ var $ = require('./$') , step = $iter.step , getKeys = $.getKeys , toObject = $.toObject - , has = $.has; + , has = $.has + , findKey = createDictMethod(6); function Dict(iterable){ var dict = $.create(null); @@ -88,32 +89,36 @@ function createDictMethod(TYPE){ }; } -// true -> Dict.turn -// false -> Dict.reduce -function createDictReduce(IS_TURN){ - return function(object, mapfn, init){ - assert.fn(mapfn); - var O = toObject(object) - , keys = getKeys(O) - , length = keys.length - , i = 0 - , memo, key, result; - if(IS_TURN){ - memo = init == undefined ? new (generic(this, Dict)) : Object(init); - } else if(arguments.length < 3){ - assert(length, 'Reduce of empty object with no initial value'); - memo = O[keys[i++]]; - } else memo = Object(init); - while(length > i)if(has(O, key = keys[i++])){ - result = mapfn(memo, O[key], key, object); - if(IS_TURN){ - if(result === false)break; - } else memo = result; - } - return memo; - }; +function reduce(object, mapfn, init){ + assert.fn(mapfn); + var O = toObject(object) + , keys = getKeys(O) + , length = keys.length + , i = 0 + , memo, key; + if(arguments.length < 3){ + assert(length, 'Reduce of empty object with no initial value'); + memo = O[keys[i++]]; + } else memo = Object(init); + while(length > i)if(has(O, key = keys[i++])){ + memo = mapfn(memo, O[key], key, object); + } + return memo; +} + +function includes(object, el){ + return (el == el ? keyOf(object, el) : findKey(object, function(it){ + return it != it; + })) !== undefined; +} + +function get(object, key){ + if(has(object, key))return object[key]; +} + +function isDict(it){ + return $.isObject(it) && $.getProto(it) === Dict.prototype; } -var findKey = createDictMethod(6); $def($def.G + $def.F, {Dict: Dict}); @@ -129,21 +134,11 @@ $def($def.S, 'Dict', { find: createDictMethod(5), findKey: findKey, mapPairs: createDictMethod(7), - reduce: createDictReduce(false), - turn: createDictReduce(true), + reduce: reduce, keyOf: keyOf, - includes: function(object, el){ - return (el == el ? keyOf(object, el) : findKey(object, function(it){ - return it != it; - })) !== undefined; - }, - // Has / get / set own property - has: has, - get: function(object, key){ - if(has(object, key))return object[key]; - }, - set: $.def, - isDict: function(it){ - return $.isObject(it) && $.getProto(it) === Dict.prototype; - } + includes: includes, + has: has, + get: get, + set: $.def, + isDict: isDict }); \ No newline at end of file diff --git a/library/modules/js.array.statics.js b/library/modules/js.array.statics.js index 8efc2ca68a03..c67d3192da6c 100644 --- a/library/modules/js.array.statics.js +++ b/library/modules/js.array.statics.js @@ -12,5 +12,5 @@ function setStatics(keys, length){ setStatics('pop,reverse,shift,keys,values,entries', 1); setStatics('indexOf,every,some,forEach,map,filter,find,findIndex,includes', 3); setStatics('join,slice,concat,push,splice,unshift,sort,lastIndexOf,' + - 'reduce,reduceRight,copyWithin,fill,turn'); + 'reduce,reduceRight,copyWithin,fill'); $def($def.S, 'Array', statics); \ No newline at end of file diff --git a/modules/core.dict.js b/modules/core.dict.js index 78c6519fde66..9546ebe169d7 100644 --- a/modules/core.dict.js +++ b/modules/core.dict.js @@ -10,7 +10,8 @@ var $ = require('./$') , step = $iter.step , getKeys = $.getKeys , toObject = $.toObject - , has = $.has; + , has = $.has + , findKey = createDictMethod(6); function Dict(iterable){ var dict = $.create(null); @@ -88,32 +89,36 @@ function createDictMethod(TYPE){ }; } -// true -> Dict.turn -// false -> Dict.reduce -function createDictReduce(IS_TURN){ - return function(object, mapfn, init){ - assert.fn(mapfn); - var O = toObject(object) - , keys = getKeys(O) - , length = keys.length - , i = 0 - , memo, key, result; - if(IS_TURN){ - memo = init == undefined ? new (generic(this, Dict)) : Object(init); - } else if(arguments.length < 3){ - assert(length, 'Reduce of empty object with no initial value'); - memo = O[keys[i++]]; - } else memo = Object(init); - while(length > i)if(has(O, key = keys[i++])){ - result = mapfn(memo, O[key], key, object); - if(IS_TURN){ - if(result === false)break; - } else memo = result; - } - return memo; - }; +function reduce(object, mapfn, init){ + assert.fn(mapfn); + var O = toObject(object) + , keys = getKeys(O) + , length = keys.length + , i = 0 + , memo, key; + if(arguments.length < 3){ + assert(length, 'Reduce of empty object with no initial value'); + memo = O[keys[i++]]; + } else memo = Object(init); + while(length > i)if(has(O, key = keys[i++])){ + memo = mapfn(memo, O[key], key, object); + } + return memo; +} + +function includes(object, el){ + return (el == el ? keyOf(object, el) : findKey(object, function(it){ + return it != it; + })) !== undefined; +} + +function get(object, key){ + if(has(object, key))return object[key]; +} + +function isDict(it){ + return $.isObject(it) && $.getProto(it) === Dict.prototype; } -var findKey = createDictMethod(6); $def($def.G + $def.F, {Dict: Dict}); @@ -129,21 +134,11 @@ $def($def.S, 'Dict', { find: createDictMethod(5), findKey: findKey, mapPairs: createDictMethod(7), - reduce: createDictReduce(false), - turn: createDictReduce(true), + reduce: reduce, keyOf: keyOf, - includes: function(object, el){ - return (el == el ? keyOf(object, el) : findKey(object, function(it){ - return it != it; - })) !== undefined; - }, - // Has / get / set own property - has: has, - get: function(object, key){ - if(has(object, key))return object[key]; - }, - set: $.def, - isDict: function(it){ - return $.isObject(it) && $.getProto(it) === Dict.prototype; - } + includes: includes, + has: has, + get: get, + set: $.def, + isDict: isDict }); \ No newline at end of file diff --git a/modules/js.array.statics.js b/modules/js.array.statics.js index 8efc2ca68a03..c67d3192da6c 100644 --- a/modules/js.array.statics.js +++ b/modules/js.array.statics.js @@ -12,5 +12,5 @@ function setStatics(keys, length){ setStatics('pop,reverse,shift,keys,values,entries', 1); setStatics('indexOf,every,some,forEach,map,filter,find,findIndex,includes', 3); setStatics('join,slice,concat,push,splice,unshift,sort,lastIndexOf,' + - 'reduce,reduceRight,copyWithin,fill,turn'); + 'reduce,reduceRight,copyWithin,fill'); $def($def.S, 'Array', statics); \ No newline at end of file diff --git a/tests/commonjs.ls b/tests/commonjs.ls index 65c167c8be7d..50908d221f87 100644 --- a/tests/commonjs.ls +++ b/tests/commonjs.ls @@ -40,7 +40,6 @@ for P in <[.. ../library]> ok Array.isArray require("#P/fn/array/of") \q \w \e ok \next of require("#P/fn/array/values")([]) ok require("#P/fn/array/includes")([1 2 3], 2) - ok require("#P/fn/array/turn")([1, 2, 3], (-> it.q++), {q: 0}).q is 3 ok typeof require("#P/fn/array/concat") is \function ok typeof require("#P/fn/array/every") is \function ok typeof require("#P/fn/array/filter") is \function @@ -193,7 +192,6 @@ for P in <[.. ../library]> ok \setImmediate of require("#P/web") ok typeof require("#P/core/$for") is \function ok require("#P/core/_") - ok \turn of require("#P/core/array") ok \format of require("#P/core/date") ok typeof require("#P/core/delay") is \function ok typeof require("#P/core/dict") is \function diff --git a/tests/tests-library.js b/tests/tests-library.js index 622be0d20ffa..c21c25b0a163 100644 --- a/tests/tests-library.js +++ b/tests/tests-library.js @@ -141,32 +141,6 @@ }); }).call(this); -// Generated by LiveScript 1.3.1 -(function(){ - var isFunction, turn, toString$ = {}.toString; - QUnit.module('core-js Array#turn'); - isFunction = function(it){ - return toString$.call(it).slice(8, -1) === 'Function'; - }; - turn = core.Array.turn; - test('*', function(){ - var arr, obj; - ok(isFunction(turn), 'Is function'); - turn(arr = [1], function(memo, val, key, that){ - deepEqual([], memo, 'Default memo is array'); - ok(val === 1, 'First argumert is value'); - ok(key === 0, 'Second argumert is index'); - return ok(that === arr, 'Third argumert is array'); - }); - turn([1], function(memo){ - return ok(memo === obj, 'Can reduce to exist object'); - }, obj = {}); - deepEqual([3, 2, 1], turn([1, 2, 3], function(memo, it){ - return memo.unshift(it); - }), 'Reduce to object and return it'); - }); -}).call(this); - // Generated by LiveScript 1.3.1 (function(){ var isFunction, toString$ = {}.toString; @@ -557,35 +531,6 @@ return toString$.call(it).slice(8, -1) === 'String'; })); }); - test('.turn', function(){ - var turn, obj; - turn = Dict.turn; - ok(isFunction(turn), 'Is function'); - turn(obj = { - q: 1 - }, function(memo, val, key, that){ - deepEqual(memo, Dict()); - ok(val === 1); - ok(key === 'q'); - return ok(that === obj); - }); - turn({ - q: 1 - }, function(it){ - return ok(it === obj); - }, obj = {}); - deepEqual(turn({ - q: 1, - w: 2, - e: 3 - }, function(memo, it){ - return memo[it] = it; - }), Dict({ - 1: 1, - 2: 2, - 3: 3 - })); - }); test('.includes', function(){ var includes, dict, o; includes = Dict.includes; @@ -4836,7 +4781,7 @@ slice = Array.prototype.slice; test('are functions', function(){ var i$, x$, ref$, len$; - for (i$ = 0, len$ = (ref$ = ['concat', 'join', 'pop', 'push', 'reverse', 'shift', 'slice', 'sort', 'splice', 'unshift', 'indexOf', 'lastIndexOf', 'every', 'some', 'forEach', 'map', 'filter', 'reduce', 'reduceRight', 'copyWithin', 'fill', 'find', 'findIndex', 'keys', 'values', 'entries', 'turn', 'includes']).length; i$ < len$; ++i$) { + for (i$ = 0, len$ = (ref$ = ['concat', 'join', 'pop', 'push', 'reverse', 'shift', 'slice', 'sort', 'splice', 'unshift', 'indexOf', 'lastIndexOf', 'every', 'some', 'forEach', 'map', 'filter', 'reduce', 'reduceRight', 'copyWithin', 'fill', 'find', 'findIndex', 'keys', 'values', 'entries', 'includes']).length; i$ < len$; ++i$) { x$ = ref$[i$]; ok(isFunction(core.Array[x$]), "Array." + x$ + " is function"); } @@ -5389,37 +5334,6 @@ done: true }); }); - test('.turn', function(){ - var turn, al, obj; - turn = core.Array.turn; - turn(al = function(){ - return arguments; - }(1), function(memo, val, key, that){ - deepEqual([], memo); - ok(val === 1); - ok(key === 0); - return ok(that === al); - }); - turn(al = '1', function(memo, val, key, that){ - deepEqual([], memo); - ok(val === '1'); - ok(key === 0); - return ok(that == al); - }); - turn(function(){ - return arguments; - }(1), function(it){ - return ok(it === obj); - }, obj = {}); - deepEqual([3, 2, 1], turn(function(){ - return arguments; - }(1, 2, 3), function(memo, it){ - return memo.unshift(it); - })); - deepEqual(['3', '2', '1'], turn('123', function(memo, it){ - return memo.unshift(it); - })); - }); test('.includes', function(){ var includes, args, o, str; includes = core.Array.includes; diff --git a/tests/tests-library/core.array.turn.ls b/tests/tests-library/core.array.turn.ls deleted file mode 100644 index 0d15c7b0f778..000000000000 --- a/tests/tests-library/core.array.turn.ls +++ /dev/null @@ -1,14 +0,0 @@ -QUnit.module 'core-js Array#turn' -isFunction = -> typeof! it is \Function -{turn} = core.Array -test '*' !-> - ok isFunction(turn), 'Is function' - turn arr = [1], (memo, val, key, that)-> - deepEqual [] memo, 'Default memo is array' - ok val is 1, 'First argumert is value' - ok key is 0, 'Second argumert is index' - ok that is arr, 'Third argumert is array' - turn [1], (memo)-> - ok memo is obj, 'Can reduce to exist object' - , obj = {} - deepEqual [3 2 1], turn([1 2 3], (memo, it)-> memo.unshift it), 'Reduce to object and return it' \ No newline at end of file diff --git a/tests/tests-library/core.dict.ls b/tests/tests-library/core.dict.ls index 0f9340f088d4..b01e11bf1076 100644 --- a/tests/tests-library/core.dict.ls +++ b/tests/tests-library/core.dict.ls @@ -144,18 +144,6 @@ test '.some' !-> , ctx = {} ok not some {q:1 w:2 e:3} -> typeof! it is \String ok some {q:1 w:\2 e:3} -> typeof! it is \String -test '.turn' !-> - {turn} = Dict - ok isFunction(turn), 'Is function' - turn (obj = q: 1), (memo, val, key, that)-> - deepEqual memo, Dict! - ok val is 1 - ok key is \q - ok that is obj - turn {q:1} -> - ok it is obj - , obj = {} - deepEqual turn({q:1 w:2 e:3} (memo, it)-> memo[it] = it), Dict {1:1 2:2 3:3} test '.includes' !-> {includes} = Dict ok isFunction(includes), 'Is function' diff --git a/tests/tests-library/js.array.statics.ls b/tests/tests-library/js.array.statics.ls index 228e57ef4e79..1c40a577b53f 100644 --- a/tests/tests-library/js.array.statics.ls +++ b/tests/tests-library/js.array.statics.ls @@ -5,7 +5,7 @@ eq = strictEqual isFunction = -> typeof! it is \Function {slice} = Array:: test 'are functions' !-> - for <[concat join pop push reverse shift slice sort splice unshift indexOf lastIndexOf every some forEach map filter reduce reduceRight copyWithin fill find findIndex keys values entries turn includes]> + for <[concat join pop push reverse shift slice sort splice unshift indexOf lastIndexOf every some forEach map filter reduce reduceRight copyWithin fill find findIndex keys values entries includes]> ok isFunction(core.Array[..]), "Array.#{..} is function" test '.join' !-> {join} = core.Array @@ -242,23 +242,6 @@ test '.entries' !-> deepEqual iter2.next!, {value: [1 \w], done: no} deepEqual iter2.next!, {value: [2 \e], done: no} deepEqual iter2.next!, {value: void, done: on} -test '.turn' !-> - {turn} = core.Array - turn (al = (->&)(1)), (memo, val, key, that)-> - deepEqual [] memo - ok val is 1 - ok key is 0 - ok that is al - turn (al = \1), (memo, val, key, that)-> - deepEqual [] memo - ok val is \1 - ok key is 0 - ok that ~= al - turn (->&)(1), -> - ok it is obj - , obj = {} - deepEqual [3 2 1], turn (->&)(1 2 3), ((memo, it)-> memo.unshift it) - deepEqual [\3 \2 \1], turn \123, ((memo, it)-> memo.unshift it) test '.includes' !-> {includes} = core.Array ok isFunction(includes), 'Is function' diff --git a/tests/tests.js b/tests/tests.js index 75e82c3ac64e..beedbab16600 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -140,32 +140,6 @@ }); }).call(this); -// Generated by LiveScript 1.3.1 -(function(){ - var isFunction, toString$ = {}.toString; - QUnit.module('core-js Array#turn'); - isFunction = function(it){ - return toString$.call(it).slice(8, -1) === 'Function'; - }; - test('*', function(){ - var arr, obj; - ok(isFunction(Array.prototype.turn), 'Is function'); - (arr = [1]).turn(function(memo, val, key, that){ - deepEqual([], memo, 'Default memo is array'); - ok(val === 1, 'First argumert is value'); - ok(key === 0, 'Second argumert is index'); - return ok(that === arr, 'Third argumert is array'); - }); - [1].turn(function(memo){ - return ok(memo === obj, 'Can reduce to exist object'); - }, obj = {}); - deepEqual([3, 2, 1], [1, 2, 3].turn(function(memo, it){ - return memo.unshift(it); - }), 'Reduce to object and return it'); - ok('turn' in Array.prototype[Symbol.unscopables], 'In Array#@@unscopables'); - }); -}).call(this); - // Generated by LiveScript 1.3.1 (function(){ var isFunction, toString$ = {}.toString; @@ -552,35 +526,6 @@ return toString$.call(it).slice(8, -1) === 'String'; })); }); - test('.turn', function(){ - var turn, obj; - turn = Dict.turn; - ok(isFunction(turn), 'Is function'); - turn(obj = { - q: 1 - }, function(memo, val, key, that){ - deepEqual(memo, Dict()); - ok(val === 1); - ok(key === 'q'); - return ok(that === obj); - }); - turn({ - q: 1 - }, function(it){ - return ok(it === obj); - }, obj = {}); - deepEqual(turn({ - q: 1, - w: 2, - e: 3 - }, function(memo, it){ - return memo[it] = it; - }), Dict({ - 1: 1, - 2: 2, - 3: 3 - })); - }); test('.includes', function(){ var includes, dict, o; includes = Dict.includes; @@ -5310,7 +5255,7 @@ slice = Array.prototype.slice; test('are functions', function(){ var i$, x$, ref$, len$; - for (i$ = 0, len$ = (ref$ = ['concat', 'join', 'pop', 'push', 'reverse', 'shift', 'slice', 'sort', 'splice', 'unshift', 'indexOf', 'lastIndexOf', 'every', 'some', 'forEach', 'map', 'filter', 'reduce', 'reduceRight', 'copyWithin', 'fill', 'find', 'findIndex', 'keys', 'values', 'entries', 'turn', 'includes']).length; i$ < len$; ++i$) { + for (i$ = 0, len$ = (ref$ = ['concat', 'join', 'pop', 'push', 'reverse', 'shift', 'slice', 'sort', 'splice', 'unshift', 'indexOf', 'lastIndexOf', 'every', 'some', 'forEach', 'map', 'filter', 'reduce', 'reduceRight', 'copyWithin', 'fill', 'find', 'findIndex', 'keys', 'values', 'entries', 'includes']).length; i$ < len$; ++i$) { x$ = ref$[i$]; ok(isFunction(Array[x$]), "Array." + x$ + " is function"); } @@ -5863,37 +5808,6 @@ done: true }); }); - test('.turn', function(){ - var turn, al, obj; - turn = Array.turn; - turn(al = function(){ - return arguments; - }(1), function(memo, val, key, that){ - deepEqual([], memo); - ok(val === 1); - ok(key === 0); - return ok(that === al); - }); - turn(al = '1', function(memo, val, key, that){ - deepEqual([], memo); - ok(val === '1'); - ok(key === 0); - return ok(that == al); - }); - turn(function(){ - return arguments; - }(1), function(it){ - return ok(it === obj); - }, obj = {}); - deepEqual([3, 2, 1], turn(function(){ - return arguments; - }(1, 2, 3), function(memo, it){ - return memo.unshift(it); - })); - deepEqual(['3', '2', '1'], turn('123', function(memo, it){ - return memo.unshift(it); - })); - }); test('.includes', function(){ var includes, args, o, str; includes = Array.includes; diff --git a/tests/tests/core.array.turn.ls b/tests/tests/core.array.turn.ls deleted file mode 100644 index 69b4249ade54..000000000000 --- a/tests/tests/core.array.turn.ls +++ /dev/null @@ -1,14 +0,0 @@ -QUnit.module 'core-js Array#turn' -isFunction = -> typeof! it is \Function -test '*' !-> - ok isFunction(Array::turn), 'Is function' - (arr = [1])turn (memo, val, key, that)-> - deepEqual [] memo, 'Default memo is array' - ok val is 1, 'First argumert is value' - ok key is 0, 'Second argumert is index' - ok that is arr, 'Third argumert is array' - [1]turn (memo)-> - ok memo is obj, 'Can reduce to exist object' - , obj = {} - deepEqual [3 2 1] [1 2 3]turn((memo, it)-> memo.unshift it), 'Reduce to object and return it' - ok \turn of Array::[Symbol.unscopables], 'In Array#@@unscopables' \ No newline at end of file diff --git a/tests/tests/core.dict.ls b/tests/tests/core.dict.ls index d53b4b76575b..64976d4b1620 100644 --- a/tests/tests/core.dict.ls +++ b/tests/tests/core.dict.ls @@ -144,18 +144,6 @@ test '.some' !-> , ctx = {} ok not some {q:1 w:2 e:3} -> typeof! it is \String ok some {q:1 w:\2 e:3} -> typeof! it is \String -test '.turn' !-> - {turn} = Dict - ok isFunction(turn), 'Is function' - turn (obj = q: 1), (memo, val, key, that)-> - deepEqual memo, Dict! - ok val is 1 - ok key is \q - ok that is obj - turn {q:1} -> - ok it is obj - , obj = {} - deepEqual turn({q:1 w:2 e:3} (memo, it)-> memo[it] = it), Dict {1:1 2:2 3:3} test '.includes' !-> {includes} = Dict ok isFunction(includes), 'Is function' diff --git a/tests/tests/js.array.statics.ls b/tests/tests/js.array.statics.ls index 57827de708f3..29f410c42a13 100644 --- a/tests/tests/js.array.statics.ls +++ b/tests/tests/js.array.statics.ls @@ -2,7 +2,7 @@ QUnit.module 'Array statics' isFunction = -> typeof! it is \Function {slice} = Array:: test 'are functions' !-> - for <[concat join pop push reverse shift slice sort splice unshift indexOf lastIndexOf every some forEach map filter reduce reduceRight copyWithin fill find findIndex keys values entries turn includes]> + for <[concat join pop push reverse shift slice sort splice unshift indexOf lastIndexOf every some forEach map filter reduce reduceRight copyWithin fill find findIndex keys values entries includes]> ok isFunction(Array[..]), "Array.#{..} is function" test '.join' !-> {join} = Array @@ -239,23 +239,6 @@ test '.entries' !-> deepEqual iter2.next!, {value: [1 \w], done: no} deepEqual iter2.next!, {value: [2 \e], done: no} deepEqual iter2.next!, {value: void, done: on} -test '.turn' !-> - {turn} = Array - turn (al = (->&)(1)), (memo, val, key, that)-> - deepEqual [] memo - ok val is 1 - ok key is 0 - ok that is al - turn (al = \1), (memo, val, key, that)-> - deepEqual [] memo - ok val is \1 - ok key is 0 - ok that ~= al - turn (->&)(1), -> - ok it is obj - , obj = {} - deepEqual [3 2 1], turn (->&)(1 2 3), ((memo, it)-> memo.unshift it) - deepEqual [\3 \2 \1], turn \123, ((memo, it)-> memo.unshift it) test '.includes' !-> {includes} = Array ok isFunction(includes), 'Is function'