source: node_modules/victory-vendor/lib-vendor/d3-array/src/rank.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.0 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = rank;
7var _ascending = _interopRequireDefault(require("./ascending.js"));
8var _sort = require("./sort.js");
9function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10function rank(values, valueof = _ascending.default) {
11 if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
12 let V = Array.from(values);
13 const R = new Float64Array(V.length);
14 if (valueof.length !== 2) V = V.map(valueof), valueof = _ascending.default;
15 const compareIndex = (i, j) => valueof(V[i], V[j]);
16 let k, r;
17 Uint32Array.from(V, (_, i) => i).sort(valueof === _ascending.default ? (i, j) => (0, _sort.ascendingDefined)(V[i], V[j]) : (0, _sort.compareDefined)(compareIndex)).forEach((j, i) => {
18 const c = compareIndex(j, k === undefined ? j : k);
19 if (c >= 0) {
20 if (k === undefined || c > 0) k = j, r = i;
21 R[j] = r;
22 } else {
23 R[j] = NaN;
24 }
25 });
26 return R;
27}
Note: See TracBrowser for help on using the repository browser.