-
Notifications
You must be signed in to change notification settings - Fork 5
CommonJS example: make difference smaller #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mathiasbynens
wants to merge
1
commit into
wycats:master
Choose a base branch
from
mathiasbynens:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,19 +13,19 @@ JavaScript Next. | |
|
|
||
| ```js | ||
| var bytes = require("bytes"); | ||
| var iconv = require("iconv-lite"); | ||
| var getCodec = require("iconv-lite").getCodec; | ||
|
|
||
| module.exports = function(stream, options, done) { | ||
| // ... | ||
| } | ||
| }; | ||
|
|
||
| // ... | ||
|
|
||
| function getDecoder(encoding) { | ||
| if (!encoding) return null; | ||
|
|
||
| try { | ||
| return iconv.getCodec(encoding).decoder() | ||
| return getCodec(encoding).decoder(); | ||
| } catch(e) { | ||
| // ... | ||
| } | ||
|
|
@@ -48,7 +48,7 @@ function getDecoder (encoding) { | |
| if (!encoding) return null; | ||
|
|
||
| try { | ||
| return getCodec(encoding).decoder() | ||
| return getCodec(encoding).decoder(); | ||
| } catch(e) { | ||
| // ... | ||
| } | ||
|
|
@@ -65,20 +65,20 @@ function getDecoder (encoding) { | |
| var cookies = require('./lib/cookies') | ||
| , copy = require('./lib/copy') | ||
| , Request = require('./request') | ||
| , util = require('util') | ||
| , _extend = require('util')._extend | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
| ; | ||
|
|
||
| function initParams(uri, options, callback) { | ||
| // ... | ||
| opts = util._extend({}, options); | ||
| opts = _extend({}, options); | ||
| // ... | ||
| } | ||
|
|
||
| // ... | ||
|
|
||
| function request (uri, options, callback) { | ||
| function request(uri, options, callback) { | ||
| // ... | ||
| opts = util._extend({}, options); | ||
| opts = _extend({}, options); | ||
| // ... | ||
| } | ||
|
|
||
|
|
@@ -89,62 +89,62 @@ request.Request = Request; | |
| request.debug = process.env.NODE_DEBUG && | ||
| /request/.test(process.env.NODE_DEBUG); | ||
|
|
||
| request.initParams = initParams | ||
| request.initParams = initParams; | ||
|
|
||
| request.defaults = function (options, requester) { | ||
| // ... | ||
|
|
||
| de.get = def(request.get) | ||
| de.patch = def(request.patch) | ||
| de.post = def(request.post) | ||
| de.put = def(request.put) | ||
| de.head = def(request.head) | ||
| de.del = def(request.del) | ||
| de.cookie = def(request.cookie) | ||
| de.jar = request.jar | ||
| de.get = def(request.get); | ||
| de.patch = def(request.patch); | ||
| de.post = def(request.post); | ||
| de.put = def(request.put); | ||
| de.head = def(request.head); | ||
| de.del = def(request.del); | ||
| de.cookie = def(request.cookie); | ||
| de.jar = request.jar; | ||
|
|
||
| return de | ||
| return de; | ||
| } | ||
|
|
||
| // ... | ||
|
|
||
| request.forever = function (agentOptions, optionsArg) { | ||
| // ... | ||
|
|
||
| return request.defaults(options) | ||
| } | ||
| return request.defaults(options); | ||
| }; | ||
|
|
||
| request.get = function (uri, options, callback) { | ||
| // ... | ||
| } | ||
| }; | ||
|
|
||
| request.post = function (uri, options, callback) { | ||
| // ... | ||
| } | ||
| }; | ||
|
|
||
| request.put = function (uri, options, callback) { | ||
| // ... | ||
| } | ||
| }; | ||
|
|
||
| request.patch = function (uri, options, callback) { | ||
| // ... | ||
| } | ||
| }; | ||
|
|
||
| request.head = function (uri, options, callback) { | ||
| // ... | ||
| } | ||
| }; | ||
|
|
||
| request.del = function (uri, options, callback) { | ||
| // ... | ||
| } | ||
| }; | ||
|
|
||
| request.jar = function (uri, options, callback) { | ||
| // ... | ||
| } | ||
| }; | ||
|
|
||
| request.cookie = function (uri, options, callback) { | ||
| // ... | ||
| } | ||
| }; | ||
| ``` | ||
|
|
||
| ```js | ||
|
|
@@ -175,29 +175,29 @@ export { Request }; | |
| export var debug = process.env.NODE_DEBUG && | ||
| /request/.test(process.env.NODE_DEBUG); | ||
|
|
||
| export var initParams = initParams | ||
| export var initParams = initParams; | ||
|
|
||
| export function defaults (options, requester) { | ||
| // ... | ||
|
|
||
| de.get = def(get) | ||
| de.patch = def(patch) | ||
| de.post = def(post) | ||
| de.put = def(put) | ||
| de.head = def(head) | ||
| de.del = def(del) | ||
| de.cookie = def(cookie) | ||
| de.jar = jar | ||
| de.get = def(get); | ||
| de.patch = def(patch); | ||
| de.post = def(post); | ||
| de.put = def(put); | ||
| de.head = def(head); | ||
| de.del = def(del); | ||
| de.cookie = def(cookie); | ||
| de.jar = jar; | ||
|
|
||
| return de | ||
| return de; | ||
| } | ||
|
|
||
| // ... | ||
|
|
||
| export function forever (agentOptions, optionsArg) { | ||
| // ... | ||
|
|
||
| return defaults(options) | ||
| return defaults(options); | ||
| } | ||
|
|
||
| export function get (uri, options, callback) { | ||
|
|
@@ -243,16 +243,16 @@ diff](https://gist.github.com/wycats/4353447a213d3060e23f/revisions) | |
| * Module dependencies | ||
| */ | ||
|
|
||
| var bytes = require('bytes') | ||
| var read = require('./read') | ||
| var typer = require('media-typer') | ||
| var typeis = require('type-is') | ||
| var bytes = require('bytes'); | ||
| var read = require('./read'); | ||
| var typer = require('media-typer'); | ||
| var typeis = require('type-is'); | ||
|
|
||
| /** | ||
| * Module exports | ||
| */ | ||
|
|
||
| module.exports = json | ||
| module.exports = json; | ||
|
|
||
| // ... | ||
|
|
||
|
|
@@ -302,7 +302,7 @@ function mkdirP (p, opts, f, made) { | |
| // ... | ||
| mkdirP(path.dirname(p), opts, function (er, made) { | ||
| // ... | ||
| }) | ||
| }); | ||
| // ... | ||
| } | ||
|
|
||
|
|
@@ -314,7 +314,7 @@ mkdirP.sync = function sync (p, opts, made) { | |
| // ... | ||
| made = sync(path.dirname(p), opts, made); | ||
| // ... | ||
| } | ||
| }; | ||
| ``` | ||
|
|
||
| ```js | ||
|
|
@@ -330,7 +330,7 @@ export default function mkdirP (p, opts, f, made) { | |
| // ... | ||
| mkdirP(dirname(p), opts, function (er, made) { | ||
| // ... | ||
| }) | ||
| }); | ||
| // ... | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s no reason to do this in the ES6 version but not here, IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason was purely because that is how it was done in the original source. But you're right, this is an example and parity is useful.
I'll noodle on it.