-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5a088b
commit 0cd2b20
Showing
18 changed files
with
85 additions
and
89 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
This file contains 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- '12' | ||
- '10' | ||
- '8' | ||
- '6' | ||
addons: | ||
chrome: stable |
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
'use strict'; | ||
// Karma.conf that reads an environment variable to decide which test to run. | ||
// Karma config that reads an environment variable to decide which test to run | ||
module.exports = require('./create-karma-conf')(process.env.ANY_OBSERVABLE_TEST_PATH); |
This file contains 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 |
---|---|---|
@@ -1,41 +1,41 @@ | ||
'use strict'; | ||
|
||
const REGISTRATION_KEY = Symbol('@@any-observable/REGISTRATION'); | ||
let registered = null; | ||
|
||
module.exports = (global, loadImplementation) => { | ||
return (implementation, opts) => { | ||
opts = opts || {}; | ||
let isRegistered; | ||
|
||
// global registration unless explicitly {global: false} in options (default true) | ||
const registerGlobal = opts.global !== false; | ||
module.exports = (global, loadImplementation) => { | ||
return (implementation, options = {}) => { | ||
// Global registration unless explicitly `{global: false}`` in options (default true) | ||
const registerGlobal = options.global !== false; | ||
|
||
// Load any previous global registration | ||
if (registerGlobal && !registered) { | ||
registered = global[REGISTRATION_KEY]; | ||
if (registerGlobal && !isRegistered) { | ||
isRegistered = global[REGISTRATION_KEY]; | ||
} | ||
|
||
if (registered && implementation && registered.implementation !== implementation) { | ||
throw new Error(`any-observable already defined as "${registered.implementation}". You can only register an implementation before the first call to require('any-observable') and an implementation cannot be changed`); | ||
if (isRegistered && implementation && isRegistered.implementation !== implementation) { | ||
throw new Error(`any-observable already defined as \`${isRegistered.implementation}\`. You can only register an implementation before the first call to \`require('any-observable')\` and an implementation cannot be changed`); | ||
} | ||
|
||
if (!registered) { | ||
if (!isRegistered) { | ||
// Use provided implementation | ||
if (implementation && opts.Observable) { | ||
registered = { | ||
Observable: opts.Observable, | ||
if (implementation && options.Observable) { | ||
isRegistered = { | ||
Observable: options.Observable, | ||
implementation | ||
}; | ||
} else { | ||
// Require implementation if implementation is specified but not provided | ||
registered = loadImplementation(implementation || null); | ||
isRegistered = loadImplementation(implementation); | ||
} | ||
|
||
if (registerGlobal) { | ||
// Register preference globally in case multiple installations | ||
global[REGISTRATION_KEY] = registered; | ||
global[REGISTRATION_KEY] = isRegistered; | ||
} | ||
} | ||
|
||
return registered; | ||
return isRegistered; | ||
}; | ||
}; |
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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