UNPKG

@chuxingpay/basic

Version:

package contains general json data such as currency codes, bed types, facility type, bank list, branch/group list etc.

43 lines (34 loc) 988 B
"use strict"; function CurrencyMap() { var data = require("../lib/CurrencyMap.json"); Object.defineProperty(this, "list", { configurable: false, enumerable: true, get: function get() { return data; } }); Object.defineProperty(this, "codes", { configurable: false, enumerable: true, get: function get() { return data.map(function (item) { return item.code; }); } }); this.find = function (name) { return data.filter(item => Object.values(item).indexOf(name) !== -1); }; this.findOne = function (name) { return data.find(item => Object.values(item).indexOf(name) !== -1) || {}; }; this.codeToSymbol = function (code) { var match = data.find(item => item.code === code) || {} return match.symbol || "" } this.symbolToCode = function (symbol) { var match = data.find(item => item.symbol === symbol) || {} return match.code || "" } return this; }; module.exports = new CurrencyMap();