Skip to content

Commit ae28cce

Browse files
authored
mirage: Replace assert() from @ember/debug with conditional throw (#10367)
The `@ember/debug` import makes it harder to use the mirage code outside of an Ember.js context. This commit replaces the import with an `if + throw` combination. The main advantage of `assert()` is that it is compiled out of production code, but since the mirage code is not shipped to production anyway, this advantage doesn't actually apply here.
1 parent 235606f commit ae28cce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mirage/serializers/crate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { assert } from '@ember/debug';
2-
31
import prerelease from 'semver/functions/prerelease';
42
import semverSort from 'semver/functions/rsort';
53

@@ -67,7 +65,9 @@ export default BaseSerializer.extend({
6765

6866
_adjust(hash, includes) {
6967
let versions = this.schema.versions.where({ crateId: hash.id });
70-
assert(`crate \`${hash.name}\` has no associated versions`, versions.length !== 0);
68+
if (versions.length === 0) {
69+
throw new Error(`crate \`${hash.name}\` has no associated versions`);
70+
}
7171

7272
let versionsByNum = Object.fromEntries(versions.models.map(it => [it.num, it]));
7373
let versionNums = Object.keys(versionsByNum);

0 commit comments

Comments
 (0)