main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import _objectAssign from "./_objectAssign.js";
|
---|
| 2 | import _identity from "./_identity.js";
|
---|
| 3 | import _isArrayLike from "./_isArrayLike.js";
|
---|
| 4 | import _isTransformer from "./_isTransformer.js";
|
---|
| 5 | import objOf from "../objOf.js";
|
---|
| 6 | var _stepCatArray = {
|
---|
| 7 | '@@transducer/init': Array,
|
---|
| 8 | '@@transducer/step': function (xs, x) {
|
---|
| 9 | xs.push(x);
|
---|
| 10 | return xs;
|
---|
| 11 | },
|
---|
| 12 | '@@transducer/result': _identity
|
---|
| 13 | };
|
---|
| 14 | var _stepCatString = {
|
---|
| 15 | '@@transducer/init': String,
|
---|
| 16 | '@@transducer/step': function (a, b) {
|
---|
| 17 | return a + b;
|
---|
| 18 | },
|
---|
| 19 | '@@transducer/result': _identity
|
---|
| 20 | };
|
---|
| 21 | var _stepCatObject = {
|
---|
| 22 | '@@transducer/init': Object,
|
---|
| 23 | '@@transducer/step': function (result, input) {
|
---|
| 24 | return _objectAssign(result, _isArrayLike(input) ? objOf(input[0], input[1]) : input);
|
---|
| 25 | },
|
---|
| 26 | '@@transducer/result': _identity
|
---|
| 27 | };
|
---|
| 28 | export default function _stepCat(obj) {
|
---|
| 29 | if (_isTransformer(obj)) {
|
---|
| 30 | return obj;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | if (_isArrayLike(obj)) {
|
---|
| 34 | return _stepCatArray;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | if (typeof obj === 'string') {
|
---|
| 38 | return _stepCatString;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | if (typeof obj === 'object') {
|
---|
| 42 | return _stepCatObject;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | throw new Error('Cannot create transformer for ' + obj);
|
---|
| 46 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.