-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (35 loc) · 1.21 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const $ = require('./base');
require('./func');
const Iter = require('./iter');
const AsIt = require('./as-it');
Iter.AsIt = AsIt;
AsIt.Iter = Iter;
Object.defineProperty(Iter.prototype, 'AsIt', {get() { return this.$.AsIt; }});
Object.defineProperty(AsIt.prototype, 'Iter', {get() { return this.$.Iter; }});
Iter.value_(function toAsIt(iter) {
return new this.AsIt(iter);
});
Iter.value_(function pipe(iter, to, opts) {
const stream = this.$.stream.call(this, iter, to, opts);
return new this.AsIt(stream);
});
Iter.value_(function pipes(iter, to, opts) {
const stream = this.$.streams.call(this, iter, to, opts);
return new this.AsIt(stream);
});
Iter.value_(function race(iter, chunk, ...args) {
const asIt = AsIt.race.gen.call(this, iter, chunk, ...args);
return new this.AsIt(asIt);
});
$.func_(Iter.objectsKeys.bind(Iter), 'keys');
$.func_(Iter.objectsValues.bind(Iter), 'values');
$.func_(Iter.objectsEntries.bind(Iter), 'entries');
$.func_(function pure(obj, ...parts) {
if (obj != null) Object.setPrototypeOf(obj, null);
else obj = Object.create(null);
if (parts.length) Iter.from(parts).toObject(obj);
return obj;
});
Object.assign($, {Iter, AsIt});
require('./func2');
module.exports = $;