MCPcopy Create free account
hub / github.com/ember-cli/ember-cli / pushUnique

Function pushUnique

lib/models/package-info-cache/package-info.js:28–48  ·  view source on GitHub ↗
(array, entry)

Source from the content-addressed store, hash-verified

26}
27
28function pushUnique(array, entry) {
29 const index = array.indexOf(entry);
30
31 if (index > -1) {
32 // the entry already exists in the array, but since the presedence between
33 // addons is "last right wins". We first remove the duplicate entry, and
34 // append it to the end of the array.
35 array.splice(index, 1);
36 }
37
38 // At this point, the entry is not in the array. So we must append it.
39 array.push(entry);
40
41 // All this ensures:
42 // pushUnique([a1,a2,a3], a1)
43 // results in:
44 //
45 // [a2, a3, a1]
46 //
47 // which results in the most "least surprising" addon ordering.
48}
49
50/**
51 * Class that stores information about a single package (directory tree with

Callers 1

addPackagesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…