diff --git a/ordered-insert.js b/ordered-insert.js deleted file mode 100644 index b0cee6e..0000000 --- a/ordered-insert.js +++ /dev/null @@ -1,23 +0,0 @@ - -/** - * insert the new item such that the array stays ordered from highest to lowest - * @param {number[]} arr array of numbers to be mutated - * @param {number} val value to insert - * @returns {void} arr is mutated - */ -export default function orderedInsert (arr, val) { - for (let i=0; i < arr.length; i++) { - if (arr[i] <= val) { - - // shift down all of the entries after the insert location by 1 - for (let idx=arr.length-1; idx >= i; idx--) - arr[idx+1] = arr[idx] - - arr[i] = val - - return - } - } - - arr.push(val) -} diff --git a/package.json b/package.json index 4d210c2..249dc32 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "type": "git", "url": "git+https://github.com/mreinstein/ecs.git" }, - "author": "", + "author": "Michael Reinstein", "license": "MIT", "bugs": { "url": "https://github.com/mreinstein/ecs/issues" diff --git a/test/orderedInsert.js b/test/orderedInsert.js deleted file mode 100644 index f2e7c3e..0000000 --- a/test/orderedInsert.js +++ /dev/null @@ -1,24 +0,0 @@ -import orderedInsert from '../ordered-insert.js' -import tap from 'tap' - - -function randomInt (min, max) { - const d = max - min - return min + Math.floor(d * Math.random()) -} - - -const a = [ ] - - -for (let i=0; i < 10; i++) { - const val = randomInt(1, 100) - orderedInsert(a, val) -} - - -let last = a[0] -for (let i=1; i < a.length; i++) { - tap.ok(last >= a[i], 'sorts highest to lowest') - last = a[i] -} diff --git a/types/ecs.d.ts.map b/types/ecs.d.ts.map index dcbe78c..eb2562c 100644 --- a/types/ecs.d.ts.map +++ b/types/ecs.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"ecs.d.ts","sourceRoot":"","sources":["../ecs.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;GAKG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;;;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AM,CAAA;CACzB;;0BASS;IAAE,CAAE,GAAG,EAAE,MAAM,GAAI,QAAQ,CAAA;CAAE;;WAKhC,WAAW;aACX,WAAW;;wBAIR;IAAE,CAAE,QAAQ,EAAE,MAAM,GAAI,kBAAkB,CAAA;CAAE;;cAK/C,MAAM,EAAE;;;;gBACR,MAAM,EAAE;;;iBAKR,MAAM;;;;oBACN;QAAE,CAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAAA;KAAE;;;;2BAC3B;QAAE,CAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAAA;KAAE;aAC3B;QACL,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE;YACb,CAAQ,GAAG,EAAE,MAAM,GAAI,MAAM,CAAC;SACzB,CAAC;KACH,EAAE;;;;;mBACI,MAAM;;;;kBAEN,MAAM;;;cAKN,MAAM,EAAE;aACR,SAAS;aACT,MAAM,EAAE;eACR,iBAAiB;sBACjB,kBAAkB;WAClB,UAAU"} \ No newline at end of file diff --git a/types/ordered-insert.d.ts b/types/ordered-insert.d.ts deleted file mode 100644 index 2b75af8..0000000 --- a/types/ordered-insert.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * insert the new item such that the array stays ordered from highest to lowest - * @param {number[]} arr array of numbers to be mutated - * @param {number} val value to insert - * @returns {void} arr is mutated - */ -export default function orderedInsert(arr: number[], val: number): void; -//# sourceMappingURL=ordered-insert.d.ts.map \ No newline at end of file diff --git a/types/ordered-insert.d.ts.map b/types/ordered-insert.d.ts.map deleted file mode 100644 index d349838..0000000 --- a/types/ordered-insert.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ordered-insert.d.ts","sourceRoot":"","sources":["../ordered-insert.js"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,2CAJW,MAAM,EAAE,OACR,MAAM,GACJ,IAAI,CAiBhB"} \ No newline at end of file