├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── .verb.md ├── LICENSE ├── README.md ├── index.js └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | end_of_line = lf 7 | charset = utf-8 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | insert_final_newline = false 15 | 16 | [{,test/}{actual,fixtures}/**] 17 | trim_trailing_whitespace = false 18 | insert_final_newline = false 19 | 20 | [templates/**] 21 | trim_trailing_whitespace = false 22 | insert_final_newline = false 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Enforce Unix newlines 2 | * text eol=lf 3 | 4 | # binaries 5 | *.ai binary 6 | *.psd binary 7 | *.jpg binary 8 | *.gif binary 9 | *.png binary 10 | *.jpeg binary 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.sublime-* 3 | _gh_pages 4 | bower_components 5 | node_modules 6 | npm-debug.log 7 | actual 8 | test/actual 9 | temp 10 | tmp 11 | TODO.md 12 | vendor 13 | .idea 14 | benchmark 15 | coverage 16 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "asi": false, 3 | "boss": true, 4 | "curly": true, 5 | "eqeqeq": true, 6 | "eqnull": true, 7 | "esnext": true, 8 | "immed": true, 9 | "latedef": false, 10 | "laxcomma": false, 11 | "mocha": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "node": true, 15 | "sub": true, 16 | "undef": true, 17 | "unused": true 18 | } 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - "0.10" 5 | - "0.12" 6 | - "0.13" 7 | - "iojs" 8 | matrix: 9 | fast_finish: true 10 | allow_failures: 11 | - node_js: "0.13" 12 | -------------------------------------------------------------------------------- /.verb.md: -------------------------------------------------------------------------------- 1 | # {%= name %} {%= badge("fury") %} 2 | 3 | > {%= description %} 4 | 5 | ## Install 6 | {%= include("install-npm", {save: true}) %} 7 | 8 | ## Usage 9 | 10 | ```js 11 | var wrap = require('{%= name %}'); 12 | ``` 13 | 14 | **Example** 15 | 16 | Pass codes for [ansi magenta background](https://github.com/jonschlinkert/ansi-bgmagenta): 17 | 18 | ```js 19 | console.log(wrap(45, 49, 'This is a message...')); 20 | //=> '\u001b[45mThis is a message...\u001b[49m' 21 | ``` 22 | 23 | Which prints out... 24 | 25 | ![screen shot 2015-05-21 at 8 28 32 pm](https://cloud.githubusercontent.com/assets/383994/7761769/12488afa-fff8-11e4-9cc1-71a8a6ec14a4.png) 26 | 27 | 28 | ## Related projects 29 | 30 | This is used in these projects: 31 | 32 | + [ansi-reset](https://github.com/jonschlinkert/ansi-reset) 33 | + [ansi-bold](https://github.com/jonschlinkert/ansi-bold) 34 | + [ansi-dim](https://github.com/jonschlinkert/ansi-dim) 35 | + [ansi-italic](https://github.com/jonschlinkert/ansi-italic) 36 | + [ansi-underline](https://github.com/jonschlinkert/ansi-underline) 37 | + [ansi-inverse](https://github.com/jonschlinkert/ansi-inverse) 38 | + [ansi-hidden](https://github.com/jonschlinkert/ansi-hidden) 39 | + [ansi-strikethrough](https://github.com/jonschlinkert/ansi-strikethrough) 40 | + [ansi-black](https://github.com/jonschlinkert/ansi-black) 41 | + [ansi-red](https://github.com/jonschlinkert/ansi-red) 42 | + [ansi-green](https://github.com/jonschlinkert/ansi-green) 43 | + [ansi-yellow](https://github.com/jonschlinkert/ansi-yellow) 44 | + [ansi-blue](https://github.com/jonschlinkert/ansi-blue) 45 | + [ansi-magenta](https://github.com/jonschlinkert/ansi-magenta) 46 | + [ansi-cyan](https://github.com/jonschlinkert/ansi-cyan) 47 | + [ansi-white](https://github.com/jonschlinkert/ansi-white) 48 | + [ansi-gray](https://github.com/jonschlinkert/ansi-gray) 49 | + [ansi-grey](https://github.com/jonschlinkert/ansi-grey) 50 | + [ansi-bgblack](https://github.com/jonschlinkert/ansi-bgblack) 51 | + [ansi-bgred](https://github.com/jonschlinkert/ansi-bgred) 52 | + [ansi-bggreen](https://github.com/jonschlinkert/ansi-bggreen) 53 | + [ansi-bgyellow](https://github.com/jonschlinkert/ansi-bgyellow) 54 | + [ansi-bgblue](https://github.com/jonschlinkert/ansi-bgblue) 55 | + [ansi-bgmagenta](https://github.com/jonschlinkert/ansi-bgmagenta) 56 | + [ansi-bgcyan](https://github.com/jonschlinkert/ansi-bgcyan) 57 | + [ansi-bgwhite](https://github.com/jonschlinkert/ansi-bgwhite) 58 | 59 | ## Running tests 60 | {%= include("tests") %} 61 | 62 | ## Contributing 63 | {%= include("contributing") %} 64 | 65 | ## Author 66 | {%= include("author") %} 67 | 68 | ## License 69 | {%= copyright() %} 70 | {%= license() %} 71 | 72 | *** 73 | 74 | {%= include("footer") %} 75 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015, Jon Schlinkert. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ansi-wrap [![NPM version](https://badge.fury.io/js/ansi-wrap.svg)](http://badge.fury.io/js/ansi-wrap) 2 | 3 | > Create ansi colors by passing open and close codes. 4 | 5 | ## Install 6 | 7 | Install with [npm](https://www.npmjs.com/) 8 | 9 | ```sh 10 | $ npm i ansi-wrap --save 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | var wrap = require('ansi-wrap'); 17 | ``` 18 | 19 | **Example** 20 | 21 | Pass codes for [ansi magenta background](https://github.com/jonschlinkert/ansi-bgmagenta): 22 | 23 | ```js 24 | console.log(wrap(45, 49, 'This is a message...')); 25 | //=> '\u001b[45mThis is a message...\u001b[49m' 26 | ``` 27 | 28 | Which prints out... 29 | 30 | [![screen shot 2015-05-21 at 8 28 32 pm](https://cloud.githubusercontent.com/assets/383994/7761769/12488afa-fff8-11e4-9cc1-71a8a6ec14a4.png)](https://www.npmjs.com/) 31 | 32 | ## Related projects 33 | 34 | This is used in these projects: 35 | 36 | * [ansi-reset](https://github.com/jonschlinkert/ansi-reset) 37 | * [ansi-bold](https://github.com/jonschlinkert/ansi-bold) 38 | * [ansi-dim](https://github.com/jonschlinkert/ansi-dim) 39 | * [ansi-italic](https://github.com/jonschlinkert/ansi-italic) 40 | * [ansi-underline](https://github.com/jonschlinkert/ansi-underline) 41 | * [ansi-inverse](https://github.com/jonschlinkert/ansi-inverse) 42 | * [ansi-hidden](https://github.com/jonschlinkert/ansi-hidden) 43 | * [ansi-strikethrough](https://github.com/jonschlinkert/ansi-strikethrough) 44 | * [ansi-black](https://github.com/jonschlinkert/ansi-black) 45 | * [ansi-red](https://github.com/jonschlinkert/ansi-red) 46 | * [ansi-green](https://github.com/jonschlinkert/ansi-green) 47 | * [ansi-yellow](https://github.com/jonschlinkert/ansi-yellow) 48 | * [ansi-blue](https://github.com/jonschlinkert/ansi-blue) 49 | * [ansi-magenta](https://github.com/jonschlinkert/ansi-magenta) 50 | * [ansi-cyan](https://github.com/jonschlinkert/ansi-cyan) 51 | * [ansi-white](https://github.com/jonschlinkert/ansi-white) 52 | * [ansi-gray](https://github.com/jonschlinkert/ansi-gray) 53 | * [ansi-grey](https://github.com/jonschlinkert/ansi-grey) 54 | * [ansi-bgblack](https://github.com/jonschlinkert/ansi-bgblack) 55 | * [ansi-bgred](https://github.com/jonschlinkert/ansi-bgred) 56 | * [ansi-bggreen](https://github.com/jonschlinkert/ansi-bggreen) 57 | * [ansi-bgyellow](https://github.com/jonschlinkert/ansi-bgyellow) 58 | * [ansi-bgblue](https://github.com/jonschlinkert/ansi-bgblue) 59 | * [ansi-bgmagenta](https://github.com/jonschlinkert/ansi-bgmagenta) 60 | * [ansi-bgcyan](https://github.com/jonschlinkert/ansi-bgcyan) 61 | * [ansi-bgwhite](https://github.com/jonschlinkert/ansi-bgwhite) 62 | 63 | ## Running tests 64 | 65 | Install dev dependencies: 66 | 67 | ```sh 68 | $ npm i -d && npm test 69 | ``` 70 | 71 | ## Contributing 72 | 73 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/ansi-wrap/issues/new) 74 | 75 | ## Author 76 | 77 | **Jon Schlinkert** 78 | 79 | + [github/jonschlinkert](https://github.com/jonschlinkert) 80 | + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) 81 | 82 | ## License 83 | 84 | Copyright © 2015 Jon Schlinkert 85 | Released under the MIT license. 86 | 87 | *** 88 | 89 | _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 24, 2015._ -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(a, b, msg) { 4 | return '\u001b['+ a + 'm' + msg + '\u001b[' + b + 'm'; 5 | }; 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ansi-wrap", 3 | "description": "Create ansi colors by passing open and close codes.", 4 | "version": "0.1.0", 5 | "homepage": "https://github.com/jonschlinkert/ansi-wrap", 6 | "author": { 7 | "name": "Jon Schlinkert", 8 | "url": "https://github.com/jonschlinkert" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/jonschlinkert/ansi-wrap.git" 13 | }, 14 | "bugs": { 15 | "url": "https://github.com/jonschlinkert/ansi-wrap/issues" 16 | }, 17 | "license": { 18 | "type": "MIT", 19 | "url": "https://github.com/jonschlinkert/ansi-wrap/blob/master/LICENSE" 20 | }, 21 | "files": [ 22 | "index.js" 23 | ], 24 | "main": "index.js", 25 | "engines": { 26 | "node": ">=0.10.0" 27 | }, 28 | "scripts": { 29 | "test": "mocha" 30 | }, 31 | "dependencies": {}, 32 | "devDependencies": {}, 33 | "keywords": [] 34 | } 35 | --------------------------------------------------------------------------------