1.0.0 • Published 6 years ago
presto-on v1.0.0
PON
URL-friendly human-readable object notation for reactive Page Rendering State Observer (PRESTO) models of state change.
Install
npm install presto-on
Usage
import PON from 'presto-on'
const encoded = PON.stringify({ hello: 'world' })
const decoded = PON.parse('hello-world')
const encodedCustom = PON.stringify(
{ hello: 'world', test: { key: 'value' } },
{ eq: ':', sep: ',', in: '(', out: ')' }
)
const decodedCustom = PON.parse(
encodedCustom,
{ eq: ':', sep: ',', in: '(', out: ')' }
)
const merger = PON.merge(
{ a: 'A', b:'C', c: 'C', sup: { hello: 'city' } },
{ b: 'B', sup: { hello: 'world' } },
{ c: null }
)
const mergeRemove = PON.merge(
PON.parse('hello-world_extra-data'),
PON.parse('extra-')
)
const stateInto = { hello: 'city', extra: 'data' }
const stateReplace = { hello: 'city', extra: 'data' }
PON.mergeInto(stateInto, { hello: 'world' }, { extra: null }, { a: 'A' })
PON.mergeReplace(stateReplace, { a: 'A' }, { b: 'B' })
const equality = PON.equal({ abc: 123 }, { abc: 123 })
console.log(encoded) /* hello-world */
console.log(decoded) /* { hello: 'world' } */
console.log(encodedCustom) /* hello:world,test(key:value */
console.log(decodedCustom) /* { hello: 'world', test: { key: 'value' } } */
console.log(merger) /* { a: 'A', b: 'B', sup: { hello: 'world' } } */
console.log(mergeRemove) /* { hello: 'world' } */
console.log(stateInto) /* { hello: 'world', a: 'A' } */
console.log(stateReplace) /* { a: 'A', b: 'B' } */
console.log(equality) /* True */
1.0.0
6 years ago
0.5.0
6 years ago
0.4.2
6 years ago
0.4.1
6 years ago
0.4.0
6 years ago
0.3.6
6 years ago
0.3.5
6 years ago
0.3.4
6 years ago
0.3.3
6 years ago
0.3.2
6 years ago
0.3.1
6 years ago
0.3.0
6 years ago
0.2.1
6 years ago
0.2.0
6 years ago
0.1.4
6 years ago
0.1.3
6 years ago
0.1.2
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago