-
Notifications
You must be signed in to change notification settings - Fork 8
Support sr.bind()
#9
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
goto-bus-stop
wants to merge
1
commit into
default
Choose a base branch
from
bound
base: default
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var sr = require('split-require') | ||
|
||
var load1 = sr.bind(null, './one') | ||
var load2 = sr.bind(null, './two') | ||
|
||
load1(function () { | ||
load2(function () {}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(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})({"entry2":[function(require,module,exports){ | ||
require("split-require").l(2, require("a")); | ||
},{"a":2,"split-require":"split-require"}],2:[function(require,module,exports){ | ||
module.exports = 'one' | ||
|
||
},{}]},{},["entry2"]); |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(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})({"entry3":[function(require,module,exports){ | ||
require("split-require").l(3, require("a")); | ||
},{"a":3,"split-require":"split-require"}],3:[function(require,module,exports){ | ||
module.exports = 'two' | ||
|
||
},{}]},{},["entry3"]); |
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
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})({"split_require_mappings":[function(require,module,exports){ | ||
require("split-require").b = {"2":"bundle.2.js","3":"bundle.3.js"}; | ||
},{"split-require":"split-require"}],1:[function(require,module,exports){ | ||
var sr = require('split-require') | ||
|
||
var load1 = sr.bind(null, 2) | ||
var load2 = sr.bind(null, 3) | ||
|
||
load1(function () { | ||
load2(function () {}) | ||
}) | ||
|
||
},{"split-require":"split-require"}],"split-require":[function(require,module,exports){ | ||
// Store dynamic bundle exports. | ||
var cache = {} | ||
// Store dynamic bundle loading callbacks, in case the same module is imported | ||
// multiple times simultaneously. | ||
var receivers = {} | ||
|
||
function load (index, cb) { | ||
// We already have this bundle. | ||
if (cache[index]) { | ||
if (cb) setTimeout(cb.bind(null, null, cache[index]), 0) | ||
return | ||
} | ||
|
||
var url = load.b[index] | ||
// TODO throw an error if we don't have the url | ||
|
||
// Combine callbacks if another one was already registered. | ||
var prev = receivers[index] | ||
receivers[index] = onload | ||
|
||
function onload (err, result) { | ||
if (prev) prev(err, result) | ||
else if (!err) cache[index] = result | ||
if (cb) cb(err, result) | ||
delete receivers[index] | ||
} | ||
|
||
// The <script> element for this bundle was already added. | ||
if (prev) return | ||
|
||
var s = document.createElement('script') | ||
s.async = true | ||
s.type = 'application/javascript' | ||
s.src = url | ||
s.onerror = function () { | ||
onload(Error('Failed to load')) | ||
} | ||
document.body.appendChild(s) | ||
} | ||
|
||
// Called by dynamic bundles once they have loaded. | ||
function loadedBundle (index, result) { | ||
if (receivers[index]) { | ||
receivers[index](null, result) | ||
} else { | ||
cache[index] = result | ||
} | ||
} | ||
|
||
// "Load" a module that we know is included in this bundle. | ||
var nextTick = window.setImmediate || window.setTimeout | ||
function loadLocal (requirer, onload) { | ||
nextTick(function () { | ||
// Just execute the module if no callback is provided | ||
if (!onload) return requirer() | ||
try { | ||
onload(null, requirer()) | ||
} catch (err) { | ||
onload(err) | ||
} | ||
}) | ||
} | ||
|
||
// Map dynamic bundle entry point IDs to URLs. | ||
load.b = {} | ||
|
||
// Used by the bundle. | ||
load.l = loadedBundle | ||
load.t = loadLocal | ||
|
||
module.exports = load | ||
|
||
},{}]},{},["split_require_mappings",1]); |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'one' |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'two' |
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.
can also use this code for
sr.call(null, 'whatever')
, i think.