datainout
Version:
Import and reports data
42 lines (40 loc) • 1.5 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/helpers/sort-by-address.ts
var sort_by_address_exports = {};
__export(sort_by_address_exports, {
sortByAddress: () => sortByAddress
});
module.exports = __toCommonJS(sort_by_address_exports);
function reverseString(str) {
return str.split("").reverse().join("");
}
function sortByAddress(arr, mode = "ASC") {
return arr.sort((a, b) => {
if (!a.address) return 1;
if (!b.address) return -1;
if (a.address === b.address) return 0;
const result = reverseString(a.address).localeCompare(reverseString(b.address));
return result * (mode === "DESC" ? -1 : 1);
});
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
sortByAddress
});