setup repo
This commit is contained in:
parent
73861ddcb9
commit
9c472a52f2
|
@ -0,0 +1,34 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# Commenting this out is preferred by some people, see
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
|
||||
node_modules
|
||||
|
||||
# Users Environment Variables
|
||||
.lock-wscript
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
|
||||
# Coveralls token files
|
||||
.coveralls.yml
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
# 1.x release
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- Major: initial public release
|
49
README.md
49
README.md
|
@ -1,2 +1,49 @@
|
|||
# node-fetch
|
||||
|
||||
node-fetch
|
||||
==========
|
||||
|
||||
[![npm version][npm-image]][npm-url]
|
||||
[![build status][travis-image]][travis-url]
|
||||
|
||||
A light-weight module that brings window.fetch to node.js
|
||||
|
||||
|
||||
# Motivation
|
||||
|
||||
I really like the notion of Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch): it bridges the API gap between client-side and server-side http requests, so developers have less to worry about.
|
||||
|
||||
But I think the term [isomorphic](http://isomorphic.net/) is generally misleading: it gives developers a false impression that their javascript code will happily run on both controlled server environment as well as uncontrollable user browsers. When the latter is only true for a subset of modern browsers, not to mention browser quirks.
|
||||
|
||||
Plus if you are going all the way to implement `XMLHttpRequest` in node and then promisify it, why not go from node's `http` to `fetch` API directly? Your browserify build are going to be vastly different from node anyway.
|
||||
|
||||
|
||||
# Features
|
||||
|
||||
* Stay consistent with `window.fetch` API.
|
||||
* Make conscious trade-off when following [WHATWG fetch spec](https://fetch.spec.whatwg.org/) implementation details, document known difference.
|
||||
* Use native promise, but allow substituting it with [insert your favorite promise library].
|
||||
|
||||
|
||||
# Install
|
||||
|
||||
`npm install node-fetch --save`
|
||||
|
||||
|
||||
# Usage
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
# Limit
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
# License
|
||||
|
||||
MIT
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/node-fetch.svg?style=flat-square
|
||||
[npm-url]: https://www.npmjs.com/package/node-fetch
|
||||
[travis-image]: https://img.shields.io/travis/bitinn/node-fetch.svg?style=flat-square
|
||||
[travis-url]: https://travis-ci.org/bitinn/node-fetch
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
/**
|
||||
* index.js
|
||||
*
|
||||
* export fetch
|
||||
*/
|
||||
|
||||
var parser = require('url');
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var zlib = require('zlib');
|
||||
|
||||
module.exports = Fetch;
|
||||
|
||||
/**
|
||||
* Create an instance of Decent
|
||||
*
|
||||
* @param String url Absolute url
|
||||
* @param Object opts Fetch options
|
||||
* @return Promise
|
||||
*/
|
||||
function Fetch(url, opts) {
|
||||
|
||||
if (!(this instanceof Fetch))
|
||||
return new Fetch(url, opts);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
Fetch.Promise = global.Promise;
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "node-fetch",
|
||||
"version": "0.1.0",
|
||||
"description": "A light-weight module that brings window.fetch to node.js",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha test/test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bitinn/node-fetch.git"
|
||||
},
|
||||
"keywords": [
|
||||
"fetch",
|
||||
"http",
|
||||
"promise"
|
||||
],
|
||||
"author": "David Frank",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bitinn/node-fetch/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bitinn/node-fetch",
|
||||
"devDependencies": {
|
||||
"chai": "^1.10.0",
|
||||
"chai-as-promised": "^4.1.1",
|
||||
"mocha": "^2.1.0"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue