Comparison of selected data serialization formats.
- JSON - ECMA-404
- EDN - github.com/edn-format/edn
- CLJ - clojure.org/reader
|| JSON | EDN | CLJ
| function render() { | |
| return ( | |
| ['aside', { id: 'sidebar' }, | |
| ['div', { className: 'sidebar' }, | |
| ['div', { className: ['container', 'sidebar-sticky'] }, | |
| ['div', { className: 'sidebar-about' }, | |
| ['h1', { className: 'font-accent' }, | |
| ['a', { tabindex: '1', href: site.baseurl }, | |
| site.title | |
| ], |
| // emits a value after `init` ms, then after `init * exp` ms, then `init * exp * exp` ms, etc. | |
| function expInterval(init, exp) { | |
| return Observable.create((observer) => { | |
| let n = init; | |
| let id; | |
| function next() { | |
| observer.next(n); | |
| n *= exp; | |
| id = setTimeout(next, n); |
| const MIN_DURATION = 100; | |
| ajaxRequest(href) | |
| .zip(Observable.timer(MIN_DURATION), x => x)) | |
| .subscribe(response => { | |
| // will execute after at least 100ms or longer depending on how long the request takes | |
| }); |
| import { Observable } from 'rxjs/Observable'; | |
| /** | |
| * Creates an observable that emits samples from an easing function on every animation frame | |
| * for a duration `d` ms. | |
| * | |
| * The first emitted value will be a sample form the easing function at `t = 0`, | |
| * and the last emitted value is guaranteed to be the easing function at `t = d`. | |
| * | |
| * It can be used with any of [Robert Penner's easing functions](http://robertpenner.com/easing/), |
| function filterWithAll(p$, ...others) { | |
| if (process.env.DEBUG && !p$) throw Error(); | |
| else if (others.length === 0) { | |
| return this::withLatestFrom(p$)::filter(([, p]) => p)::map(([x]) => x); | |
| } else { | |
| return this::withLatestFrom(p$, ...others) | |
| ::filter(([, ...ps]) => ps.every(p => p)) | |
| ::map(([x]) => x); | |
| } | |
| } |
| // Node 8+ | |
| // -------------------------------------------------------------- | |
| // No external dependencies | |
| const { promisify } = require('util'); | |
| const { resolve } = require('path'); | |
| const fs = require('fs'); | |
| const readdir = promisify(fs.readdir); | |
| const stat = promisify(fs.stat); |
Comparison of selected data serialization formats.
|| JSON | EDN | CLJ
| // Quick-and-Dirty `Set` implementation. | |
| /* eslint-disable */ | |
| export const Set = global.Set || function (a = []) { | |
| a = a.filter((x, i) => i === a.indexOf(x)); | |
| a.size = a.length; | |
| a.has = x => a.indexOf(x) > -1; | |
| a.add = x => { if (!a.has(x)) { a.size++; a.push(x); } return a; }; | |
| a.delete = x => { let t; if (t = a.has(x)) { a.size--; delete a[a.indexOf(x)]; } return t; }; | |
| a.keys = a.values = () => a[Symbol.iterator](); | |
| a.clear = () => { while (a.pop()) {} a.size = 0; }; |