Browse Source

[select] Select Class, and change to API

pull/1/head
Muthu Kumar 7 years ago
parent
commit
326b9999cd
  1. 2
      .eslintignore
  2. 29
      Select.js

2
.eslintignore

@ -1 +1 @@
testscript.js
testscript*.js

29
Select.js

@ -1,16 +1,21 @@
'use strict';
const Select = (value, resolve) => ({
value,
for: (test, fn) => {
if (resolve) return {
...Select(value, resolve),
resolve
};
if (test) return Select(value, fn);
return Select(value);
},
resolve: resolve ? resolve : () => undefined
});
const isIterable = val => typeof val === "object" && Symbol.iterator in val;
class Select {
constructor(value, resolve) {
this.value = value;
this.iterable = isIterable(value);
if (resolve) this.resolve = resolve;
}
for(test, consequent) {
if (test(this.value)) return new Select(this.value, consequent);
if (this.resolve) return this;
return this;
}
}
Select.prototype.resolve = () => null;
module.exports = Select;

Loading…
Cancel
Save