-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20734 from emberjs/circularity
working to remove circular dependencies
- Loading branch information
Showing
35 changed files
with
174 additions
and
128 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type EmberArray from '@ember/array'; | ||
|
||
export function objectAt<T>(array: T[] | EmberArray<T>, index: number): T | undefined { | ||
if (Array.isArray(array)) { | ||
return array[index]; | ||
} else { | ||
return array.objectAt(index); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './lib/make-array'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { DEBUG } from '@glimmer/env'; | ||
|
||
export interface AssertFunc { | ||
(desc: string, condition: unknown): asserts condition; | ||
(desc: string): never; | ||
} | ||
|
||
export let assert: AssertFunc = (() => {}) as unknown as AssertFunc; | ||
|
||
export function setAssert(implementation: typeof assert): typeof assert { | ||
assert = implementation; | ||
return implementation; | ||
} | ||
|
||
if (DEBUG) { | ||
/** | ||
Verify that a certain expectation is met, or throw a exception otherwise. | ||
This is useful for communicating assumptions in the code to other human | ||
readers as well as catching bugs that accidentally violates these | ||
expectations. | ||
Assertions are removed from production builds, so they can be freely added | ||
for documentation and debugging purposes without worries of incuring any | ||
performance penalty. However, because of that, they should not be used for | ||
checks that could reasonably fail during normal usage. Furthermore, care | ||
should be taken to avoid accidentally relying on side-effects produced from | ||
evaluating the condition itself, since the code will not run in production. | ||
```javascript | ||
import { assert } from '@ember/debug'; | ||
// Test for truthiness | ||
assert('Must pass a string', typeof str === 'string'); | ||
// Fail unconditionally | ||
assert('This code path should never be run'); | ||
``` | ||
@method assert | ||
@static | ||
@for @ember/debug | ||
@param {String} description Describes the expectation. This will become the | ||
text of the Error thrown if the assertion fails. | ||
@param {any} condition Must be truthy for the assertion to pass. If | ||
falsy, an exception will be thrown. | ||
@public | ||
@since 1.0.0 | ||
*/ | ||
function assert(desc: string): never; | ||
function assert(desc: string, test: unknown): asserts test; | ||
// eslint-disable-next-line no-inner-declarations | ||
function assert(desc: string, test?: unknown): asserts test { | ||
if (!test) { | ||
throw new Error(`Assertion Failed: ${desc}`); | ||
} | ||
} | ||
setAssert(assert); | ||
} |
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
Oops, something went wrong.