├── .eslintrc ├── .npmignore ├── test └── print.js ├── .editorconfig ├── .gitignore ├── package.json ├── lib └── index.js ├── LICENSE └── README.md /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "peerigon/es5tests", 3 | "env": { 4 | "node": true 5 | }, 6 | "root": true 7 | } 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | npm-debug.log 15 | node_modules 16 | coverage 17 | examples 18 | test 19 | assets 20 | .idea 21 | -------------------------------------------------------------------------------- /test/print.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var unicons = require("../lib/index.js"); 4 | 5 | Object.keys(unicons) 6 | .filter(function (key) { 7 | return typeof unicons[key] === "string"; 8 | }) 9 | .forEach(function (icon) { 10 | console.log(icon, unicons.cli(icon)); 11 | }); 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs. 2 | # More information at http://EditorConfig.org 3 | 4 | # No .editorconfig files above the root directory 5 | root = true 6 | 7 | [*] 8 | indent_style = space 9 | indent_size = 4 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | 14 | [package.json] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | 29 | # IDE stuff 30 | .idea 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unicons", 3 | "version": "0.0.3", 4 | "description": "Cross-platform unicode icon toolkit", 5 | "author": "peerigon", 6 | "contributors": [ 7 | { 8 | "name": "peerigon", 9 | "email": "hello@peerigon.com" 10 | }, 11 | { 12 | "name": "bmcminn", 13 | "email": "labs@gbox.name" 14 | } 15 | ], 16 | "main": "lib/index.js", 17 | "scripts": { 18 | "test": "node test/print.js", 19 | "posttest": "eslint ." 20 | }, 21 | "keywords": [ 22 | "icons", 23 | "unicode", 24 | "cli", 25 | "toolkit" 26 | ], 27 | "license": "Unlicense", 28 | "devDependencies": { 29 | "eslint": "^1.6.0", 30 | "eslint-config-peerigon": "^0.1.1" 31 | }, 32 | "repository": { 33 | "type": "git", 34 | "url": "https://github.com/peerigon/unicons.git" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | var isWin = process.platform === "win32"; 2 | 3 | var unicons = { 4 | arrowLeft: "←", 5 | arrowUp: "↑", 6 | arrowRight: "→", 7 | arrowDown: "↓", 8 | check: "✓", 9 | circle: "●", 10 | copyright: "©", 11 | cross: "✖", 12 | gear: "\u2699", 13 | option: "⌥", 14 | super: "⌘", 15 | shift: "⇧", 16 | warning: "⚠" 17 | }; 18 | 19 | var win32Cli = { 20 | arrowLeft: "\u2190", 21 | arrowUp: "\u2191", 22 | arrowRight: "\u2192", 23 | arrowDown: "\u2193", 24 | check: "\u221A", 25 | circle: "\u006F", 26 | copyright: "\u00A9", 27 | cross: "\u00D7", 28 | gear: "\u263C", 29 | option: "\u003C", 30 | shift: "\u2191", 31 | super: "\u221E", 32 | warning: "\u0021" 33 | }; 34 | 35 | unicons.cli = function (name) { 36 | var icon = isWin ? win32Cli[name] : unicons[name]; 37 | 38 | return icon || " "; // degrade gracefully to whitespace 39 | }; 40 | 41 | module.exports = unicons; 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unicons 2 | 3 | **Cross-platform unicode icon toolkit** 4 | 5 | [![](https://img.shields.io/npm/v/unicons.svg)](https://www.npmjs.com/package/unicons) 6 | [![](https://img.shields.io/npm/dm/unicons.svg)](https://www.npmjs.com/package/unicons) 7 | 8 | Provides fast access to the most commonly used unicode icons. 9 | 10 | ```javascript 11 | var unicons = require("unicons"); 12 | 13 | console.log(unicons.check); // ✓ 14 | console.log(unicons.cross); // ✖ 15 | ``` 16 | 17 | ## Installation 18 | 19 | ``` 20 | npm i unicons --save 21 | ``` 22 | 23 | ## CLI mode 24 | 25 | **unicons** has especially been designed for use in CLIs. If you want to support different OS, just call `.cli(iconName)` and you'll get the most suitable character for the given environment: 26 | 27 | ```javascript 28 | unicons.cli("circle"); // ● on Unix 29 | // o on Windows 30 | ``` 31 | 32 | ## Icon table 33 | 34 | Property | Default | Windows Console Fallback 35 | ---------|---------|-------------------------| 36 | `arrowLeft` | ← | ← 37 | `arrowUp` | ↑ | ↑ 38 | `arrowRight` | → | → 39 | `arrowDown` | ↓ | ↓ 40 | `check` | ✓ | √ 41 | `circle` | ● | o 42 | `cross` | ✖ | × 43 | `copyright` | © | c 44 | `gear` | ⚙ | ☼ 45 | `option` | ⌥ | < 46 | `super` | ⌘ | ∞ 47 | `shift` | ⇧ | ↑ 48 | `warning` | ⚠ | ! 49 | 50 | The icon table is still very small :(
51 | If you can't find your icon in the [icon table](https://github.com/peerigon/unicons#icon-table), don't hesitate to create a pull request. 52 | 53 | ## FAQ 54 | 55 | ### Why not copy-paste the characters? 56 | 57 | If you're feeling lucky, go ahead ;). Copying characters is error prone and might also include unwanted invisible characters. Furthermore, the copied character might be displayed on your computer, but not on someone elses. We think it's better to refer to a name, like `arrowLeft`, in this case. 58 | 59 | ### Will the returned string always have a `length` of `1`? 60 | 61 | [Nope, depending on the character range](https://mathiasbynens.be/notes/javascript-unicode). Besides that, we might also use two characters on oldschool consoles to represent the icon. 62 | 63 | 64 | ## Contributing 65 | 66 | Refer to these resources for integrating more characters: [symbl.cc](https://symbl.cc/en/unicode-table/) and [jrgraphix.net](http://jrgraphix.net/r/Unicode/). 67 | 68 | In order to find Windows characters, please refer to the [Codepage 437 Reference](https://en.wikipedia.org/wiki/Code_page_437). Most of these will work, however, there is no guarantee :( 69 | 70 | Before sending the pull request, please run `npm test` on a Unix and a Windows machine (using cmd.exe). 71 | 72 | ## License 73 | 74 | Unlicense 75 | 76 | ## Sponsors 77 | 78 | [](https://peerigon.com) 79 | --------------------------------------------------------------------------------