This file contains hidden or 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
| if (!Object.setPrototypeOf) { | |
| Object.setPrototypeOf = function(obj, proto) { | |
| obj.__proto__ = proto; | |
| return obj; | |
| } | |
| } | |
| Object.setPrototypeOf(NodeList.prototype, Array.prototype) | |
| Node.prototype.on = window.on = function(names, fn) { |
This file contains hidden or 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 bind = require('simulacra') | |
| var dom = require('dom') | |
| module.exports = function (update) { | |
| var template = | |
| `<div id="product"> | |
| <h1 class="name"></h1> | |
| <div class="details"> | |
| <div><span class="size"></span></div> |
This file contains hidden or 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 getOk() { | |
| return new Promise(function(resolve, reject) { | |
| setTimeout(function(){ | |
| resolve({message: 'ok'}) | |
| },5000) | |
| }); | |
| } | |
| async function main() { | |
| try { |
This file contains hidden or 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 st = require('st') | |
| var http = require('http') | |
| var port = 1337 | |
| http.createServer( | |
| st({ | |
| path: process.cwd(), | |
| cache: false | |
| }) | |
| ).listen(port) |
This file contains hidden or 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 users = [{name: 'Ben', age: 32}, {name: 'Nina', age: 31}] | |
| const agedUsers = users.map(user => Object.assign({}, user, {age: user.age + 1})) | |
| const addUser = (currentUsers, newUser) => [newUser, ...currentUsers] | |
| const updatedUserList = addUser(agedUsers, {name: 'Jack', age: 2}) | |
| console.log(updatedUserList) |
This file contains hidden or 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
| // main.js | |
| const vel = require('vel') | |
| const testElement = require('./test-element') | |
| const el = vel(function (h, state) { | |
| return <div> | |
| <h1>clicked {String(state.n)} times</h1> | |
| <button onclick={onclick}>click me!</button> | |
| {testElement(h, state, el)} |
This file contains hidden or 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 path = require('path'); | |
| var net = require('net'); | |
| var multilevel = require('multilevel'); | |
| var level = require('level'); | |
| exports.register = function (server, options, next) { | |
| var dbClient, con; | |
| var db = level(options.dbPath, { | |
| valueEncoding: 'json', |
This file contains hidden or 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
| /* | |
| * Angular JS Multi Select | |
| * Creates a dropdown-like button with checkboxes. | |
| * | |
| * Project started on: Tue, 14 Jan 2014 - 5:18:02 PM | |
| * Current version: 2.0.1 | |
| * | |
| * Released under the MIT License | |
| * -------------------------------------------------------------------------------- | |
| * The MIT License (MIT) |
This file contains hidden or 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 fruits = { | |
| apple: "apple", | |
| orange: "orange", | |
| fruitAction: function (nameOfAction, cb) { | |
| console.log("you ran " + nameOfAction); | |
| var callB = cb.bind(this); | |
| callB(); | |
| } | |
| } |
This file contains hidden or 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 http = require('http'); | |
| // var contact = {"name": "Ben", "age": 31}; | |
| var server = http.createServer(function (req, res) { | |
| var outputString = ''; | |
| req.setEncoding('utf8'); |