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 CancelablePromise = (function(){ | |
var cancelledPromiseSymbol = Symbol('PROMISE_CANCELLED'); | |
function createTypeError(message) { | |
var error = new TypeError(message); | |
var stack = error.stack.split('\n'); | |
stack.splice(1, 1); | |
stack[1] = stack[1].replace(/:\d+:\d+\)$/, ')'); | |
error.stack = stack.join('\n'); | |
throw error; |
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
{ | |
"presets": [ | |
[ | |
"env", | |
{ | |
"loose": true, | |
"targets": { | |
"node": "6.10.3" | |
} | |
} |
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
// logger - https://gist.github.com/tracker1/655be1ac690d23988816a48d52e91550 | |
import log from './logger'; | |
async function main() { | |
// TODO: main processes | |
} | |
let cleanedUp = false; | |
async function cleanup(error) { | |
if (error) log.fatal(error); |
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
import console from 'console'; | |
import process from 'process'; | |
import util from 'util'; | |
import fclone from 'fclone'; | |
import rollingFile from 'rolling-file'; | |
import mkdirp from 'mkdirp'; | |
import { packageBase } from './pkg'; | |
export const LEVELS = Object.seal({ | |
FATAL: 1000, |
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
// TODO: add process.nextTick foo so that this doesn't block as long | |
import iconv from 'iconv-lite'; | |
// UTF8 BOM - 0xEF, 0xBB, 0xBF | |
// UTF16 BOM - 0xFE, 0xFF | |
// UTF16le BOM = 0xFF, 0xFE | |
export default async function readTextFromBuffer(buffer) { | |
if (!(buffer instanceof Buffer)) throw new Error('Input is not a buffer'); |
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
// for reference: | |
// https://www.bignerdranch.com/blog/asyncing-feeling-about-javascript-generators/ | |
// https://gist.github.com/nybblr/3af62797052c42f7090b4f8614b5e157#gistcomment-2044311 | |
const destreamify = async (stream, callback) => { | |
for await (let event of stream) { | |
callback(event); | |
} | |
}; |
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
{ | |
// Enable/disable JavaScript validation. | |
// using eslint plugin instead | |
"javascript.validate.enable": false, | |
"files.autoSave": "off", | |
"editor.tabSize": 2, | |
"editor.fontFamily": "Inconsolata, Menlo, Monaco, 'Courier New', monospace", |
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 function normalizeToString(input) { | |
// string or String object | |
if (typeof input === 'string' || input instanceof String) return input.toString(); | |
// boolean value | |
if (typeof input === 'boolean') return input.toString(); | |
// numeric value | |
if (typeof input === 'number' || input instanceof Number) { | |
// not a finite value - invalid input - return empty |
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 path = require('path'); | |
const glob = require('glob'); | |
const base = path.resolve(__dirname, '../'); | |
const allScripts = glob.sync(path.join(__dirname, '../src') + '/**/*.js'); | |
const tests = allScripts.filter(s => (/\.test\.js$/).test(s)); | |
const scripts = allScripts.filter(s => !(/\.(test|disabled|unsafe)\./).test(s)); | |
const untested = scripts.filter(s => !tests.includes(s.replace(/\.js$/,'.test.js'))); |
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 request = require('request-promise'); | |
const moment = require('moment'); | |
const getId = url => request(url).then(b => JSON.parse(b).data); | |
function getSoonItems(deal, type) { | |
return deals.filter(deal => ( | |
deal.stage_id === app && deal[type.key] === type.refi || | |
deal.stage_id === app && deal[type.key] === type.purchase && deal[pbl.key] === pbl.no | |
)).reduce((obj, deal) => { ...obj, [deal.id]:deal }); |