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
"use strict" | |
exports.container = function() { | |
var head = { | |
next: null | |
} | |
this.add = function(shell) { | |
head.next = { | |
shell: shell, |
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
"use strict" | |
const newton = ({ | |
f, | |
df, | |
initialGuess, | |
tolerance = Number.EPSILON, | |
maxIterations = 1000 | |
}) => { | |
let x = initialGuess; |
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 promiseMap = function() { | |
var api = {_: {}}; | |
api._.map = {}; | |
api._.getPromiseHandle = function(id) { | |
var promiseHandle = api._.map[id]; | |
if (!promiseHandle) { | |
promiseHandle = { |
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
'use strict' | |
var mutex = require('mutex') // (this doesn't exist, it's just an illustration) | |
var playerMutexes = getPlayerMutexes() // (as above) | |
var gameBoardMutexes = getGameBoardMutexes() // (as above) | |
var getPairs = function(arr) { | |
var results = [] |
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
'use strict'; | |
var mapWithDefault = require('./mapWithDefault'); | |
module.exports = function addEventing(obj) { | |
var handlers = mapWithDefault(function() { | |
return []; | |
}); | |
obj.trigger = function(evtName) { |
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 interval = (function() { | |
var api = {}; | |
var idMap = {}; | |
var nextId = 0; | |
api.set = function(task, ms) { | |
var nextTime = Date.now() + ms; | |
var id = nextId++; | |
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
'use strict'; | |
module.exports = function stress(interDelay, spinDelay, duration) { | |
var spinLock = function(spinDuration) { | |
var start = Date.now(); | |
while (Date.now() - start < spinDuration) { | |
// Do nothing | |
} | |
}; |
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
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
# atom.workspace.observeTextEditors (editor) -> | |
# editor.onDidSave -> |
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
'use strict'; | |
var http = require('http'); | |
var fs = require('fs'); | |
var Promise = require('bluebird'); | |
var delay = function(time) { | |
return new Promise(function(resolve) { | |
setTimeout(resolve, time); | |
}); |
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
'use strict'; | |
module.exports = function(condition, loop, result) { | |
return Promise.resolve((function run() { | |
if (!condition()) { | |
return result(); | |
} | |
return loop().then(run); | |
})()); |
OlderNewer