master 01b9eb6236b9 cached
8 files
9.4 KB
3.3k tokens
1 requests
Download .txt
Repository: bengourley/currency-symbol-map
Branch: master
Commit: 01b9eb6236b9
Files: 8
Total size: 9.4 KB

Directory structure:
gitextract_k5efprls/

├── .gitignore
├── LICENSE.md
├── Readme.md
├── currency-symbol-map.d.ts
├── currency-symbol-map.js
├── map.js
├── package.json
└── test.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history


================================================
FILE: LICENSE.md
================================================
Copyright (c) 2017, Ben Gourley

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


================================================
FILE: Readme.md
================================================
# currency-symbol-map

A function to lookup the currency symbol for a given currency code.

## Installation

    npm install currency-symbol-map

## Usage

### Get symbol from currency code
```js
// ES5
const getSymbolFromCurrency = require('currency-symbol-map')

// ES6
import getSymbolFromCurrency from 'currency-symbol-map'

getSymbolFromCurrency('GBP') //=> '£'
getSymbolFromCurrency('EUR') //=> '€'
getSymbolFromCurrency('USD') //=> '$'
getSymbolFromCurrency('NOT A VALID CODE') //=> undefined
```

### Exposed map for other processing
```js
// ES5
const currencyToSymbolMap = require('currency-symbol-map/map')

// ES6
import currencyToSymbolMap from 'currency-symbol-map/map'

console.log(currencyToSymbolMap)
// =>
{
 "USD": "$",
 "GBP": "£",
 …
}
```

## Tests
```bash
npm test
```

## Changelog

### 5.1.0
- Add CNH Currency mapping: [#82](https://github.com/bengourley/currency-symbol-map/pull/82)

### 5.0.1
- upgraded linter and improved code formatting ([#63](https://github.com/bengourley/currency-symbol-map/pull/63))

### 5.0.0
- added some missing currencies ([#61](https://github.com/bengourley/currency-symbol-map/pull/61))
- fixed the BTC symbol ([#50](https://github.com/bengourley/currency-symbol-map/pull/50))
- fixed the KZT symbol ([#52](https://github.com/bengourley/currency-symbol-map/pull/52))
- fixed the SGD symbol ([#55](https://github.com/bengourley/currency-symbol-map/pull/55))
- added TypeScript typings ([#53](https://github.com/bengourley/currency-symbol-map/pull/53))
- upgraded test libraries & added extra test cases ([#62](https://github.com/bengourley/currency-symbol-map/pull/62))

### 4.0.0
- the reverse lookup feature was removed (retrieving currency given a symbol) because
there is not a deterministic way to do so (i.e. the same symbol is used by multiple currencies).
- in previous versions, an unsuccessful lookup would return the `'?'` character. It now returns
`undefined` so that it is up to you how to handle the failure.

## Credits

Currency symbols originally sourced from [xe](http://www.xe.com/symbols.php), but maintained
and updated by [contributors](https://github.com/bengourley/currency-symbol-map/pulls?q=is%3Apr+is%3Aclosed).


================================================
FILE: currency-symbol-map.d.ts
================================================
declare function getSymbolFromCurrency (currencyCode: string): string | undefined
export = getSymbolFromCurrency


================================================
FILE: currency-symbol-map.js
================================================
const currencySymbolMap = require('./map')

module.exports = function getSymbolFromCurrency (currencyCode) {
  if (typeof currencyCode !== 'string') {
    return undefined
  }

  const code = currencyCode.toUpperCase()

  if (!Object.prototype.hasOwnProperty.call(currencySymbolMap, code)) {
    return undefined
  }

  return currencySymbolMap[code]
}

module.exports.currencySymbolMap = currencySymbolMap


================================================
FILE: map.js
================================================
module.exports = {
  AED: 'د.إ',
  AFN: '؋',
  ALL: 'L',
  AMD: '֏',
  ANG: 'ƒ',
  AOA: 'Kz',
  ARS: '$',
  AUD: '$',
  AWG: 'ƒ',
  AZN: '₼',
  BAM: 'KM',
  BBD: '$',
  BDT: '৳',
  BGN: 'лв',
  BHD: '.د.ب',
  BIF: 'FBu',
  BMD: '$',
  BND: '$',
  BOB: '$b',
  BOV: 'BOV',
  BRL: 'R$',
  BSD: '$',
  BTC: '₿',
  BTN: 'Nu.',
  BWP: 'P',
  BYN: 'Br',
  BYR: 'Br',
  BZD: 'BZ$',
  CAD: '$',
  CDF: 'FC',
  CHE: 'CHE',
  CHF: 'CHF',
  CHW: 'CHW',
  CLF: 'CLF',
  CLP: '$',
  CNH: '¥',
  CNY: '¥',
  COP: '$',
  COU: 'COU',
  CRC: '₡',
  CUC: '$',
  CUP: '₱',
  CVE: '$',
  CZK: 'Kč',
  DJF: 'Fdj',
  DKK: 'kr',
  DOP: 'RD$',
  DZD: 'دج',
  EEK: 'kr',
  EGP: '£',
  ERN: 'Nfk',
  ETB: 'Br',
  ETH: 'Ξ',
  EUR: '€',
  FJD: '$',
  FKP: '£',
  GBP: '£',
  GEL: '₾',
  GGP: '£',
  GHC: '₵',
  GHS: 'GH₵',
  GIP: '£',
  GMD: 'D',
  GNF: 'FG',
  GTQ: 'Q',
  GYD: '$',
  HKD: '$',
  HNL: 'L',
  HRK: 'kn',
  HTG: 'G',
  HUF: 'Ft',
  IDR: 'Rp',
  ILS: '₪',
  IMP: '£',
  INR: '₹',
  IQD: 'ع.د',
  IRR: '﷼',
  ISK: 'kr',
  JEP: '£',
  JMD: 'J$',
  JOD: 'JD',
  JPY: '¥',
  KES: 'KSh',
  KGS: 'лв',
  KHR: '៛',
  KMF: 'CF',
  KPW: '₩',
  KRW: '₩',
  KWD: 'KD',
  KYD: '$',
  KZT: '₸',
  LAK: '₭',
  LBP: '£',
  LKR: '₨',
  LRD: '$',
  LSL: 'M',
  LTC: 'Ł',
  LTL: 'Lt',
  LVL: 'Ls',
  LYD: 'LD',
  MAD: 'MAD',
  MDL: 'lei',
  MGA: 'Ar',
  MKD: 'ден',
  MMK: 'K',
  MNT: '₮',
  MOP: 'MOP$',
  MRO: 'UM',
  MRU: 'UM',
  MUR: '₨',
  MVR: 'Rf',
  MWK: 'MK',
  MXN: '$',
  MXV: 'MXV',
  MYR: 'RM',
  MZN: 'MT',
  NAD: '$',
  NGN: '₦',
  NIO: 'C$',
  NOK: 'kr',
  NPR: '₨',
  NZD: '$',
  OMR: '﷼',
  PAB: 'B/.',
  PEN: 'S/.',
  PGK: 'K',
  PHP: '₱',
  PKR: '₨',
  PLN: 'zł',
  PYG: 'Gs',
  QAR: '﷼',
  RMB: '¥',
  RON: 'lei',
  RSD: 'Дин.',
  RUB: '₽',
  RWF: 'R₣',
  SAR: '﷼',
  SBD: '$',
  SCR: '₨',
  SDG: 'ج.س.',
  SEK: 'kr',
  SGD: 'S$',
  SHP: '£',
  SLL: 'Le',
  SOS: 'S',
  SRD: '$',
  SSP: '£',
  STD: 'Db',
  STN: 'Db',
  SVC: '$',
  SYP: '£',
  SZL: 'E',
  THB: '฿',
  TJS: 'SM',
  TMT: 'T',
  TND: 'د.ت',
  TOP: 'T$',
  TRL: '₤',
  TRY: '₺',
  TTD: 'TT$',
  TVD: '$',
  TWD: 'NT$',
  TZS: 'TSh',
  UAH: '₴',
  UGX: 'USh',
  USD: '$',
  UYI: 'UYI',
  UYU: '$U',
  UYW: 'UYW',
  UZS: 'лв',
  VEF: 'Bs',
  VES: 'Bs.S',
  VND: '₫',
  VUV: 'VT',
  WST: 'WS$',
  XAF: 'FCFA',
  XBT: 'Ƀ',
  XCD: '$',
  XOF: 'CFA',
  XPF: '₣',
  XSU: 'Sucre',
  XUA: 'XUA',
  YER: '﷼',
  ZAR: 'R',
  ZMW: 'ZK',
  ZWD: 'Z$',
  ZWL: '$'
}


================================================
FILE: package.json
================================================
{
  "name": "currency-symbol-map",
  "version": "5.1.0",
  "description": "A function to lookup the currency symbol for a given currency code",
  "main": "currency-symbol-map.js",
  "scripts": {
    "test": "standard && tape test.js | tap-spec"
  },
  "publishConfig": {
    "registry": "https://registry.npmjs.org/"
  },
  "repository": {
    "type": "git",
    "url": "git@github.com:bengourley/currency-symbol-map.git"
  },
  "keywords": [
    "currency",
    "symbol"
  ],
  "author": "Ben Gourley",
  "license": "BSD-2-Clause",
  "bugs": {
    "url": "https://github.com/bengourley/currency-symbol-map/issues"
  },
  "devDependencies": {
    "standard": "^16.0.3",
    "tap-spec": "^5.0.0",
    "tape": "^5.1.1"
  }
}


================================================
FILE: test.js
================================================
const test = require('tape')

const getSymbolFromCurrency = require('./')
const currencySymbolMap = require('./map')

test('getSymbolFromCurrency(): valid params', t => {
  t.equal('$', getSymbolFromCurrency('USD'), 'should return $ when USD is provided')
  t.equal('£', getSymbolFromCurrency('GBP'), 'should return £ when GBP is provided')
  t.equal('€', getSymbolFromCurrency('EUR'), 'should return € when EUR is provided')
  t.equal('€', getSymbolFromCurrency('eur'), 'should return € when eur is provided')
  t.equal(undefined, getSymbolFromCurrency('NON-EXISTENT-CODE'), 'should return undefined when code is non-existent')
  t.end()
})

test('getSymbolFromCurrency(): invalid params', t => {
  t.equal(undefined, getSymbolFromCurrency(1), 'should return undefined when param is not a string')
  t.equal(undefined, getSymbolFromCurrency(null), 'should return undefined when param is null')
  t.equal(undefined, getSymbolFromCurrency(false), 'should return undefined when param is false')
  t.equal(undefined, getSymbolFromCurrency(), 'should return undefined when param is undefined')
  t.end()
})

test('currency-symbol-map: sanity check every value in map', t => {
  const currencies = Object.keys(currencySymbolMap)
  const obj = {}
  currencies.forEach(code => { obj[code] = getSymbolFromCurrency(code) })
  t.deepEqual(obj, currencySymbolMap)
  t.end()
})

test('currency-symbol-map: no symbols should be missing', t => {
  for (const code in currencySymbolMap) {
    t.equal(typeof currencySymbolMap[code], 'string', `Symbol of ${code} should be a string`)
    t.isNotEqual(currencySymbolMap[code], '', `Symbol of ${code} should not be empty`)
  }
  t.end()
})

test('currency-symbol-map: codes should be in alphabetical order', t => {
  const currencies = Object.keys(currencySymbolMap)
  const sorted = Object.keys(currencySymbolMap).sort((a, b) => a.localeCompare(b))
  t.deepEqual(currencies, sorted)
  t.end()
})
Download .txt
gitextract_k5efprls/

├── .gitignore
├── LICENSE.md
├── Readme.md
├── currency-symbol-map.d.ts
├── currency-symbol-map.js
├── map.js
├── package.json
└── test.js
Condensed preview — 8 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (11K chars).
[
  {
    "path": ".gitignore",
    "chars": 545,
    "preview": "# Logs\nlogs\n*.log\nnpm-debug.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n\n# Directory for instrumented libs generated by jscov"
  },
  {
    "path": "LICENSE.md",
    "chars": 1314,
    "preview": "Copyright (c) 2017, Ben Gourley\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or withou"
  },
  {
    "path": "Readme.md",
    "chars": 2196,
    "preview": "# currency-symbol-map\n\nA function to lookup the currency symbol for a given currency code.\n\n## Installation\n\n    npm ins"
  },
  {
    "path": "currency-symbol-map.d.ts",
    "chars": 113,
    "preview": "declare function getSymbolFromCurrency (currencyCode: string): string | undefined\nexport = getSymbolFromCurrency\n"
  },
  {
    "path": "currency-symbol-map.js",
    "chars": 407,
    "preview": "const currencySymbolMap = require('./map')\n\nmodule.exports = function getSymbolFromCurrency (currencyCode) {\n  if (typeo"
  },
  {
    "path": "map.js",
    "chars": 2403,
    "preview": "module.exports = {\n  AED: 'د.إ',\n  AFN: '؋',\n  ALL: 'L',\n  AMD: '֏',\n  ANG: 'ƒ',\n  AOA: 'Kz',\n  ARS: '$',\n  AUD: '$',\n  "
  },
  {
    "path": "package.json",
    "chars": 723,
    "preview": "{\n  \"name\": \"currency-symbol-map\",\n  \"version\": \"5.1.0\",\n  \"description\": \"A function to lookup the currency symbol for "
  },
  {
    "path": "test.js",
    "chars": 1929,
    "preview": "const test = require('tape')\n\nconst getSymbolFromCurrency = require('./')\nconst currencySymbolMap = require('./map')\n\nte"
  }
]

About this extraction

This page contains the full source code of the bengourley/currency-symbol-map GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 8 files (9.4 KB), approximately 3.3k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!