UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

47 lines 2.18 kB
"use strict"; 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); var getEnumeration_exports = {}; __export(getEnumeration_exports, { findMatchingCondition: () => findMatchingCondition, getEnumeration: () => getEnumeration }); module.exports = __toCommonJS(getEnumeration_exports); const findMatchingCondition = (enumerationContent, quantity) => { const numericKeys = Object.keys(enumerationContent); for (const key of numericKeys) { const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity; const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1)); const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2)); const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1)); const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2)); if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) { return key; } } }; const getEnumeration = (enumerationContent, quantity) => { const key = findMatchingCondition(enumerationContent, quantity) ?? "fallback"; return enumerationContent[key]; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { findMatchingCondition, getEnumeration }); //# sourceMappingURL=getEnumeration.cjs.map