Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Created November 19, 2015 17:56
Show Gist options
  • Save wilmoore/121becdea0c6576074eb to your computer and use it in GitHub Desktop.
Save wilmoore/121becdea0c6576074eb to your computer and use it in GitHub Desktop.
requirebin sketch
'use strict'
var selectn = require('selectn')
var first = require('array-head')
function json (response) {
return response.json()
}
fetch('https://api.github.com/gists/public')
.then(json)
.then(first)
.then(selectn('id'))
.then(console.log.bind(console))
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"array-head":[function(require,module,exports){"use strict";module.exports=first;function first(val){return Object(val)===val&&typeof val.length==="number"?val[0]:void 0}},{}]},{},[]);require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({selectn:[function(require,module,exports){module.exports=selectn;function selectn(query){var parts;if(Array.isArray(query)){parts=query}else{query=query.replace(/\[(\d+)\]/g,".$1");parts=query.split(".")}function accessor(object){var ref=object!=null?object:(1,eval)("this");var len=parts.length;var idx=0;for(;idx<len;idx+=1){if(ref!=null)ref=ref[parts[idx]]}return ref}return arguments.length>1?accessor(arguments[1]):accessor}},{}]},{},[]);"use strict";var selectn=require("selectn");var first=require("array-head");function json(response){return response.json()}fetch("https://api.github.com/gists/public").then(json).then(first).then(selectn("id")).then(console.log.bind(console));
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"array-head": "0.1.0",
"selectn": "0.10.0"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment