s
s
spellbook
Search…
Chain Methods
This method is usable from 0.1.x version.
sb.chain([{ a: 'asdasd' }, { a: 35 }])
.reverse()
.toString()
.toJSON()
.filterBy({ a : 35 })
.first()
.repeatify(5)
.size()
.repeatify(10)
.toString()
.json()
.get('2')
.duplicate()
.repeatify(2)
.map(x => x + 1)
.contains(11)
.return()
-> true

sb.chain([{ a: 'hi' }, { a: 35 }])
.first()
.get('a')
.toUpperCase()
.return()
-> "HI"

sb.chain(100)
.numerator(2)
.mult(1002)
.toString()
.size()
.divide(2)
.sum(6)
.toString()
.split('.')
.map(sb.toInt)
.max()
.value()
-> 8

sb.chain([{ a: 'asdasd' }, { a: 35 }])
.reverse()
.toString()
.toJSON()
.filterBy({ a: 35 })
.first()
.repeatify(5)
.size()
.repeatify(10)
.toString()
.json()
.get('2')
.duplicate()
.repeatify(2)
.map(x => x + 1)
.value()
-> [11,11]

sb.chain(sb.range(1,5))
.size()
.isNumber()
.ifElse(
() => "hello",
() => "bye"
)
.function(x => `Res: ${x}`)
.value()
-> "Res: hello"

sb.on('evrec', console.log)

sb.chain('message')
.on('evrec2', (x, y) => {
console.log(`${y} : ${x}`)
})
.value()
-> "message"

sb.chain([{ a: 'asdasd' }, { a: 35 }])
.reverse()
.toString()
.toJSON()
.filterBy({ a: 35 })
.first()
.repeatify(5)
.size()
.repeatify(10)
.toString()
.json()
.get('2')
.duplicate()
.repeatify(2)
.map(x => x + 1)
.emit('evrec')
.value()
-> Rec: 11 -> [11,11]
Last modified 2yr ago
Copy link
On this page
Can chain any method from Spellbook
For return a value can use method "value()", "return()", "v()" or "r()"
Playing with chain
Chaining comparision and functions
Make a normal event
Make an event from chain
Emit from chain