Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

V5 beta6 #50

Open
wants to merge 136 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
a715630
🖇❔ isEmpty, move isJSON, 🔬 tests
aretecode Jul 17, 2017
b9f3af3
🚚⚪️ move frisbee module/example 🆙 update it
aretecode Jul 17, 2017
2e4dafd
🆓🎁 start fp with prop, pipe, path, map, curry
aretecode Jul 17, 2017
e905ccf
🖇❔ is/ ℹ docblocks 🆓 use some curry, isArguments
aretecode Jul 17, 2017
ec97334
🖇🗝️ keys for objOrArray utils
aretecode Jul 17, 2017
37c9ff8
🖇 reduce; use 🆓 fp on 🛁 clean
aretecode Jul 17, 2017
56ae957
minor docblock adjustments, isBuffer, links, metadata
aretecode Jul 17, 2017
6360f00
📘⛓ SwitchChain example
aretecode Jul 18, 2017
b8220df
📘⛓ example: RegExp chain
aretecode Jul 18, 2017
03e41c1
📘⛓ example: ObjectDefineChain
aretecode Jul 18, 2017
2e77777
🎱 add InstancePooler with tests
aretecode Jul 19, 2017
922429a
🆓🎁 more fp 🔬 more tests ℹ️️ more docblocks
aretecode Jul 19, 2017
d9e8f1b
🛡🆓 wrap encase: tryCatch & withSpec with curry
aretecode Jul 19, 2017
0dd28f9
🖇 conditionals utils 🆓 wrap with curry + ℹ️️
aretecode Jul 19, 2017
8a9d3c6
ℹ️️ docblocks for dot-prop 🆓 use fp/replace on escape
aretecode Jul 19, 2017
00f0e5f
🖇❔move reusable `is` functions from validator builder into files
aretecode Jul 19, 2017
f279512
🐫 add camelCase 🔬 tests + move to string/ folder
aretecode Jul 19, 2017
d923099
ℹ️️ minor naming & docs on core classes
aretecode Jul 19, 2017
9771c03
🌊 update typings
aretecode Jul 19, 2017
e30f41e
⚡perf ℹ️️ docs 👾 variable name clarity 📝 todos
aretecode Jul 19, 2017
13a1806
👣 big update 🏰 refactor ℹ️️ docs 🎱 pooler 🤸🛁
aretecode Jul 19, 2017
11bd67f
🏗 build & 🤖📖 docgen update & 📇 metadata
aretecode Jul 19, 2017
3ea81ec
📖🤖 docgen: metadata. ⚒ minor eq path require fix
aretecode Jul 19, 2017
67cd443
🛅 built dev version for links from docgen site until upgraded
aretecode Jul 19, 2017
a7aea68
🖇 noop util ⚪️⛓ frisbee
aretecode Jul 19, 2017
b15b322
tests, metadata, doc examples, examples rename, readme
aretecode Jul 20, 2017
5990326
tests, fp split arity, fp/remove, code cov, changelog
aretecode Jul 20, 2017
699e6a6
👣traverser 👾 simplify, refactor eq & copy 🔬
aretecode Jul 20, 2017
344bb6b
🔢 start OrderedMap ℹ️️🔗 docblock links 📦🐈🏗🗝️
aretecode Jul 20, 2017
dbd515c
🛅 bundle size ⚡ minor opts
aretecode Jul 20, 2017
e59fc83
🖇use more utils, ℹ️️ docblock, isNested
aretecode Jul 21, 2017
a555fc9
typedefs update, docs + docgen, metadata - JS.ORG!
aretecode Jul 22, 2017
1efab96
🆙 conditional 🐏 curry includes ℹ️ docs
aretecode Jul 22, 2017
faef99c
🔩 /native/ folder 🚚 move ignored to meta/
aretecode Jul 22, 2017
543539c
⚖️ `eq` 🛁 minor clean + ℹ️🔗 doclinks 👕lint tweaks
aretecode Jul 22, 2017
843caf9
🆙 utils/ 🕴 exports 👷 construct > new in index
aretecode Jul 22, 2017
e564ce2
🖇 util 🆕 localGlobal 🆙⛑ update & safety ℹ️️ docs
aretecode Jul 22, 2017
a7e586e
🐏 🎁 fp: ⬅️ reverse 👷 construct 📞 invoke ℹ️️ docs
aretecode Jul 22, 2017
d2f3da7
❔ is/ ℹ️ℹ️ℹ️️ docs 🆕🆕🆕 🔬 tests 🔩 native/
aretecode Jul 22, 2017
3d66b9b
- 🐏 🎁 fp/ ...again
aretecode Jul 22, 2017
08f388a
🆕 add expressions/ 🆕 add to/ 🚚 move some
aretecode Jul 22, 2017
eb95e15
🤖📖 docgen 📇 metadata 👣 Traverse ⚡ minor perf
aretecode Jul 22, 2017
1d7160c
🏗 build/ 📅 mini plan + 🖇 node utils for scripts
aretecode Jul 22, 2017
380f65b
🚧📜 easy-npm-files build export script (🐴 messy)
aretecode Jul 22, 2017
c18c1cb
🤖📖 docgen - fix links & dedupe meta + 🔎 search
aretecode Jul 22, 2017
771019a
'string'/ & [array]/ 🤸 split 🎱 pooler ℹ️ order
aretecode Jul 23, 2017
4a62312
📜 easy-npm-files part 2, export to root 🖥👕
aretecode Jul 24, 2017
a3e9d07
🔢 expressions/ ℹ️ docs 🎁 add, inc, dec, sub
aretecode Jul 25, 2017
4427c35
❔ is/ 🆙ℹ️ docs (args, arr, bool, empty, func...)
aretecode Jul 25, 2017
760d3bc
❔ is/ 🆕 finite, int, nan, plain, ww, url, el, arrlike...
aretecode Jul 25, 2017
8923e95
🖇 util/ 🆕🔚 defineFinal 🆕❄️ freeze 🆕 `kindOf` ℹ️ docs
aretecode Jul 26, 2017
c5a0d9e
❔ is/ ℹ️ + docs & links 🆕❔a few
aretecode Jul 26, 2017
06d37a4
⛰ env ℹ️ @member @private 🆕☮️ compat for poly
aretecode Jul 26, 2017
40a760f
dot-prop ℹ️ docs & 📝 todos
aretecode Jul 26, 2017
e71af85
🖇 utils & 🙃 flipped in core composed classes
aretecode Jul 26, 2017
43f7346
⚡ perf & 🎱 pooling
aretecode Jul 26, 2017
ea0860c
ℹ️ docs 🆕 nth, bind, invert, slice, times...
aretecode Jul 26, 2017
af27222
construct args, use utils, alias, 🎱new & ℹ️ docs
aretecode Jul 26, 2017
3228dbd
🆙 conditional/
aretecode Jul 26, 2017
595e52c
🕑 cast/
aretecode Jul 26, 2017
db51729
☮️ array future compat comments and functions
aretecode Jul 26, 2017
172e7b4
🏹 regexp/ 🎯 matcher/ 🆕 test()
aretecode Jul 26, 2017
81c3806
🖇🆕 values ℹ️ more docs 🎀 string/
aretecode Jul 26, 2017
bba76dc
`_` 🆕 debounce 🆕 throttle 🆕 delay
aretecode Jul 26, 2017
0aa852c
🎁🗝 add .keys method to Chainable 🕑[iterator]
aretecode Jul 26, 2017
66da471
🕴 exports.js
aretecode Jul 26, 2017
64a3f43
📜📒 Makefile 📇 metadata 🔬 tests
aretecode Jul 26, 2017
de37d39
🔁 loop/ 🆕
aretecode Jul 26, 2017
31ed505
👣 traverse ℹ️ docs ❗ BREAKING remove .traversed
aretecode Jul 26, 2017
d9f59af
⛓🚧 wip `ChainPlus`: fp + oop
aretecode Jul 26, 2017
211a4a8
👾 | pipe | simplify reducing with `pipe`
aretecode Jul 29, 2017
4adb322
⚒ fix ℹ️ docblock 📘🔬 @examples
aretecode Jul 29, 2017
f7c0971
ℹ️ docs: minor tweaks, links, alias, examples, clean
aretecode Jul 29, 2017
e91a84c
➗ math/ 📒 rename, 🆕 range, max, min, imul
aretecode Jul 29, 2017
0cbef6b
array/ 🆕ℹ️ ⚡ preAllocate
aretecode Jul 29, 2017
a6070b9
👾 simplify dotPaths
aretecode Jul 29, 2017
4d070a4
⛰ env/ ℹ️ 🆕 preferSize, preferPerf, strict
aretecode Jul 29, 2017
eb9513e
❔ is/ 📖 readme 🕴 export 🆕 new & 🆙 update
aretecode Jul 29, 2017
5688544
🎯 match/ 🕴 @member 🆕
aretecode Jul 29, 2017
86ecc94
🔣 symbols/ 🆕
aretecode Jul 29, 2017
df87ad2
fp/ 🆕🦎 👾⚡🛡
aretecode Jul 29, 2017
a8bd2c8
🏎️ /native/ 🆕 added 📒 renamed 🕴 export @member
aretecode Jul 29, 2017
13a10cb
💸 cache/ 🕴@exports 🆕 weakCache
aretecode Jul 29, 2017
7f54eba
🕑 cast/ 🆕 args,key,int,index,pairs,set,str...
aretecode Jul 29, 2017
b24da6e
🖇 util/ 🕴 exports 🤸 split keyval ...
aretecode Jul 29, 2017
37f1e8e
🖇 util/ 🆕 ⚒
aretecode Jul 29, 2017
379fac0
string/ 🆕 charCode, match, quote, 🚚 char@0
aretecode Jul 29, 2017
c4a405b
🔬 tests 🃏prep to extend jest & 🌲⛓ astchain
aretecode Jul 29, 2017
acb497e
🏗 @alias exports, minor tweaks & util & built
aretecode Jul 29, 2017
4c15acc
🍴 fork bench-chain, 🏋️ simple benchmark
aretecode Jul 29, 2017
05f0ca4
🎼 compose 📇 rename meta keys
aretecode Jul 29, 2017
63beef9
🙃 flipped/ 🆕
aretecode Jul 30, 2017
b6e2017
🔁 loop/ 🔁 each/
aretecode Jul 30, 2017
d848647
🔁 loop/ 🙃 flipped/ 🆕📖
aretecode Jul 30, 2017
764ab77
🔁 loop/ 🌈 fantasy/ 🆕
aretecode Jul 30, 2017
3bd9e65
🔁 loop/ ☕ filter/ 🆙ℹ️ filterWhere
aretecode Jul 30, 2017
6369fe7
🔁 loop/ 🗺 map/ 🆕📖📒
aretecode Jul 30, 2017
335ba0d
🔁 loop/ 🔢 sort/ ⚒⌨️
aretecode Jul 30, 2017
5ba0496
🔁 loop/ ⏬ reduce/ 🆕
aretecode Jul 30, 2017
5f305c8
🔁 loop// 🕴📖
aretecode Jul 30, 2017
ff9b204
🎚minor tweaks
aretecode Jul 30, 2017
adde40e
❗📼 Shorthands & Chainable -> es5 prototype > class
aretecode Jul 30, 2017
bd24270
🔬 tests 🃏
aretecode Jul 31, 2017
1a8d35f
⚒ fix all tests
aretecode Jul 31, 2017
f453d4a
⚒ fix isOfInstanceObj in compose
aretecode Jul 31, 2017
633be8d
ChainedSet - fix casting, convert to hybrid-class
aretecode Jul 31, 2017
f9e9677
Chainable - keyValueToIterator + fix pathchecks
aretecode Jul 31, 2017
14bf45f
`ChainedMap` to hybrid class
aretecode Jul 31, 2017
1b4561c
compose - fix fn check, Observe & Shorthands hybrid class
aretecode Jul 31, 2017
f090b7f
🚚 move `argumentor` to `cast`
aretecode Aug 2, 2017
3cdc17e
🆕 native/ (props, empty str, falsy, entries)
aretecode Aug 2, 2017
1ac4618
ℹ️
aretecode Aug 2, 2017
23073d3
🕑 cast/ 📒 rename 🆙 toDate
aretecode Aug 2, 2017
a0427f4
🕑 cast/ 🆙
aretecode Aug 2, 2017
42b81a4
⚒ fix export names in construct
aretecode Aug 2, 2017
4223e8d
ℹ️ℹ️ℹ️ docblocks 🔗
aretecode Aug 2, 2017
5ae8699
⚒ fix names & 🆙 improve 🛡
aretecode Aug 2, 2017
99bf2f3
🆕🐏❔
aretecode Aug 2, 2017
f6ebff4
update matcher
aretecode Aug 2, 2017
95d130c
🖇 utils 🆕⚡ℹ️
aretecode Aug 2, 2017
1acde8a
➗ math/ 🆕⚒ℹ️
aretecode Aug 2, 2017
2b102c0
`_`/ 🕴 export @member
aretecode Aug 2, 2017
b34a735
🔬 tests 🃏 more tests, neq, trav, debounce
aretecode Aug 2, 2017
cd7bf44
- 🔁 loop/ 🆙 map/* 🆕 reduce/*
aretecode Aug 2, 2017
f579679
🏗 @examples test runner, minor tweaks to run
aretecode Aug 2, 2017
1850a63
🏗🔊 build extensions for debugging
aretecode Aug 3, 2017
4d6a034
🙊 adjust debug logging in easy-npm-files
aretecode Aug 3, 2017
1f69fb4
nary type declarations
aretecode Aug 12, 2017
2e72341
adjust linting func-style for rollup + uglify
aretecode Aug 12, 2017
d8d5b98
babel assign polyfill (comment)
aretecode Aug 12, 2017
7ad15f4
isBooleanLike, isPromisePoly, more is/all
aretecode Aug 12, 2017
5e758c9
add more cast/ & is/
aretecode Aug 12, 2017
f4e9a03
matchBooleanIsh
aretecode Aug 12, 2017
1292497
export matchables
aretecode Aug 12, 2017
d8ea61f
upgrade fp/where + fp/pipe, lint & comments
aretecode Aug 12, 2017
d199f03
export forOwnUnguarded & forOwn in loop
aretecode Aug 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
📘⛓ SwitchChain example
  • Loading branch information
aretecode committed Jul 18, 2017
commit 6360f0085544197086ad847666d736f407517109
113 changes: 113 additions & 0 deletions examples/packages/minis/SwitchChain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
const {Chain, ChainedSet, merge, eq, is} = require('../../../')

const {isFunction, isBoolean, isArray, isString, isNull} = is
const ignoredTypes = ['null', 'undefined', 'NaN']
const simpleKindOf = x => (isArray(x) ? 'array' : isNull(x) ? 'null' : typeof x)

// @TODO find the other SwitchChain that also has break?
// needs more checks
class Switch extends Chain {
constructor(value) {
super(value)
this.cases = new ChainedSet(this)
this.value = this.parent
}

static on(value) {
return new Switch(value)
}

// could be decorate
case(value, cb) {
let check = () => {
if (eq(this.value, value)) {
return cb()
}
return false
}

if (isFunction(value)) {
check = value
}

if (isBoolean(value)) {
check = () => {
if (value) {
return cb()
}
return false
}
}

this.cases.add(check)

return this
}

// auto ending
default(cb) {
return this.set('default', cb).end()
}

end() {
for (let [condition] of this.cases) {
const result = condition()
if (result) return result
}

return this.get('default')()
}
}

// could use say matcher super easily but the point is
// being able to use the array, since === would not work with an array usually
function DopeSwitch(one, two) {
const types = [one, two].map(simpleKindOf)
const [type1, type2] = types

if (ignoredTypes.includes(type1)) return two
if (ignoredTypes.includes(type2)) return one

/* prettier-ignore */
const result = Switch
.on(types)
// strings[]
.case(['string', 'string'], () => one + two)
.case(['array', 'string'], () => one.concat([two]))
.case(['string', 'array'], () => two.concat([one]))
// primitives
.case(['string', 'number'], () => [one, two])
.case(['number', 'string'], () => [one, two])
.case(['number', 'boolean'], () => [one, two])
.case(['boolean', 'string'], () => [one, two])
.case(['boolean', 'number'], () => [one, two])
// boolean[]
.case(['boolean', 'boolean'], () => one)
.case(['array', 'boolean'], () => one.concat([two]))
.case(['boolean', 'array'], () => one.concat([two]))
// number[]
.case(['number', 'number'], () => one + two)
.case(['array', 'number'], () => one.concat([two]))
.case(['number', 'array'], () => one.concat([two]))
// concat
.default(() => merge(one, two))

return result
}

function DopeSwitchDebug(one, two) {
const key = String([one, two])
return {[key]: DopeSwitch(one, two)}
}

const merges = [
DopeSwitchDebug(1, 1),
DopeSwitchDebug('1', 1),
DopeSwitchDebug([], 100),
DopeSwitchDebug({}, {eh: true}),
DopeSwitchDebug([], []),
DopeSwitchDebug([], {}),
DopeSwitchDebug(['duck', 'duck', 'duck'], ['goose']),
]

console.log(merges)