Skip to content

Instantly share code, notes, and snippets.

@remmythical
remmythical / promiseLib.js
Last active Apr 24, 2017
Promisifying callback-oriented nodejs libs with ES6 (example)
View promiseLib.js
export default function getPromiseLib(lib) {
return new Proxy(lib, {
get: (target, prop) => (...args) =>
new Promise((resolve, reject) => {
target[prop](...args, (err, ...params) => {
if (err) {
reject(err);
} else {
resolve(params);
}
View attraktorreminder.js
var ical = require('ical'),
twit = require('twit'),
Twit = new twit({
'consumer_key': 'your_consumer_key_here',
'consumer_secret': 'your_consumer_secret_here',
'access_token': 'your_access_token_here',
'access_token_secret': 'your_access_token_secret_here'
}),
now = new Date();