This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Test extends React.Component { | |
state = this.search({ | |
find: { | |
activePanel: _`?panel`, | |
programmingLanguage: _`?pl` | |
}, | |
where: [ | |
[':app', ':panel', _`?panel`], | |
[':app', ':pl', _`?pl`] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JSON | |
var data = { | |
articles: [{ | |
title: 'article #1', | |
text: 'zero', | |
comments: [{ | |
text: 'comment #1' | |
}] | |
}, { | |
title: 'article #2', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var name = 'John'; | |
var query = { | |
find: [_`?year`, _`?month`, _`day`], | |
where: [ | |
[_`?artist`, ':artist/name', name], // data clause | |
[_`?artist`, ':artist/startDay', _`?day`], | |
[_`?artist`, ':artist/startMonth', _`?month`], | |
[_`?artist`, ':artist/startYear', _`?year`], | |
[_`?year`, y => y > 2010], // expression clause, predicate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findArtistTracklist(db, artistName) { | |
var [artist, track, year, name] = createVariables(); | |
// Query syntax is similar to the one used in d3.js | |
// Every function returns a new function | |
var allTracks = query(db) | |
.match([artist, ":artist/name", artistName]) | |
.match([track, ":track/artist", artist]) | |
.match([track, ":track/name", name]) | |
.match([track, ":track/year", year]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* range(min, max) { | |
for (var i = min; i < max; i++) { | |
yield i; | |
} | |
} | |
[...range(0, 5)] // [0, 1, 2, 3, 4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends Component { | |
state = { | |
db: createLocalStorageDb("db") | |
} | |
onDbError = error => console.log(`DbError: `, error) | |
render() { | |
var { user } = this.props; | |
var { db } = this.state; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TOGGLE_PLAY = 'TOGGLE_PLAY'; | |
const STOP = 'STOP'; | |
class App extends ReduxComponent { | |
state = { | |
isPlaying: false, | |
track: 123 | |
} | |
reduce(state, action) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myMap = new WeakMap(); | |
// We store two objects in our Weakmap | |
myMap.set(window, 'window'); | |
myMap.set(document.body, 'myelement'); | |
document.body.parentNode.removeChild(document.body); | |
myMap.get(document.body); // undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// module: YearAssesment | |
var _ = require('underscore'); | |
function shouldBePromoted(assignments, minimumPassingPercentage) { | |
if (!minimumPassingPercentage) { | |
minimumPassingPercentage = 0.6; | |
} | |
return _.compose( |
NewerOlder