ansi-escape-sequences
Advanced tools
Comparing version 0.1.0 to 0.1.1
"use strict"; | ||
/** | ||
A simple library containing all the known [ansi escape codes and sequences](http://en.wikipedia.org/wiki/ANSI_escape_code). | ||
@module | ||
@alias ansi | ||
@example | ||
```js | ||
var ansi = require("ansi-escape-sequences"); | ||
``` | ||
*/ | ||
var a = require("array-tools"); | ||
@@ -35,14 +44,60 @@ | ||
/** | ||
Moves the cursor `lines` (default 1) cells up. If the cursor is already at the edge of the screen, this has no effect | ||
*/ | ||
exports.cursorUp = function(lines){ return csi + lines + "A"; }; | ||
/** | ||
Moves the cursor `lines` (default 1) cells down. If the cursor is already at the edge of the screen, this has no effect | ||
*/ | ||
exports.cursorDown = function(lines){ return csi + lines + "B"; }; | ||
/** | ||
remove all sgr effects | ||
@const {string} | ||
*/ | ||
exports.reset = csi + "0m"; | ||
/** | ||
Bold or increased intensity | ||
@const {string} | ||
*/ | ||
exports.bold = csi + "1m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.italic = csi + "3m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.underline = csi + "4m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.imageNegative = csi + "7m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.fontDefault = csi + "10m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.font2 = csi + "11m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.font3 = csi + "12m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.font4 = csi + "13m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.font5 = csi + "14m"; | ||
/** | ||
@const {string} | ||
*/ | ||
exports.font6 = csi + "15m"; | ||
@@ -61,4 +116,9 @@ exports.imageNegative = csi + "7m"; | ||
/** | ||
@param {string} - the string to format | ||
@param {string[]} - a list of sgr effects to add | ||
@returns {string} | ||
*/ | ||
exports.format = function(str, effectArray){ | ||
return sgr.sequence(effectArray) + str + sgr.sequence("reset"); | ||
}; |
{ | ||
"name": "ansi-escape-sequences", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A library of all known ansi escape sequences", | ||
@@ -18,7 +18,11 @@ "repository": "https://github.com/75lb/ansi-escape-sequences.git", | ||
"lint": "jshint lib/*.js bin/*.js test/*.js; echo", | ||
"docs": "jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo" | ||
"docs": "jsdoc2md --index --skip-heading -t jsdoc2md/README.hbs lib/*.js > README.md; echo" | ||
}, | ||
"dependencies": { | ||
"array-tools": "^1.0.6" | ||
}, | ||
"devDependencies": { | ||
"jsdoc-to-markdown": "^0.2.14", | ||
"tape": "^2.13.3" | ||
} | ||
} |
[![view on npm](http://img.shields.io/npm/v/ansi-escape-sequences.svg)](https://www.npmjs.org/package/ansi-escape-sequences) | ||
[![npm module downloads per month](http://img.shields.io/npm/dm/ansi-escape-sequences.svg)](https://www.npmjs.org/package/ansi-escape-sequences) | ||
[![Build Status](https://travis-ci.org/75lb/ansi-escape-sequences.svg?branch=master)](https://travis-ci.org/75lb/ansi-escape-sequences) | ||
[![Dependency Status](https://david-dm.org/75lb/ansi-escape-sequences.svg)](https://david-dm.org/75lb/ansi-escape-sequences) | ||
***work in progress, draft documentation*** | ||
#ansi-escape-sequences | ||
<a name="module_ansi-escape-sequences"></a> | ||
A simple library containing all the known [ansi escape codes and sequences](http://en.wikipedia.org/wiki/ANSI_escape_code). | ||
**Example** | ||
```js | ||
var ansi = require("ansi-escape-sequences"); | ||
``` | ||
**Symbols** | ||
* [ansi.cursorUp()](#module_ansi-escape-sequences.cursorUp) | ||
* [ansi.cursorDown()](#module_ansi-escape-sequences.cursorDown) | ||
* [ansi.format(str, effectArray)](#module_ansi-escape-sequences.format) | ||
* [ansi.reset](#module_ansi-escape-sequences.reset) | ||
* [ansi.bold](#module_ansi-escape-sequences.bold) | ||
* [ansi.italic](#module_ansi-escape-sequences.italic) | ||
* [ansi.underline](#module_ansi-escape-sequences.underline) | ||
* [ansi.imageNegative](#module_ansi-escape-sequences.imageNegative) | ||
* [ansi.fontDefault](#module_ansi-escape-sequences.fontDefault) | ||
* [ansi.font2](#module_ansi-escape-sequences.font2) | ||
* [ansi.font3](#module_ansi-escape-sequences.font3) | ||
* [ansi.font4](#module_ansi-escape-sequences.font4) | ||
* [ansi.font5](#module_ansi-escape-sequences.font5) | ||
* [ansi.font6](#module_ansi-escape-sequences.font6) | ||
<a name="module_ansi-escape-sequences.cursorUp"></a> | ||
###ansi.cursorUp() | ||
Moves the cursor `lines` (default 1) cells up. If the cursor is already at the edge of the screen, this has no effect | ||
<a name="module_ansi-escape-sequences.cursorDown"></a> | ||
###ansi.cursorDown() | ||
Moves the cursor `lines` (default 1) cells down. If the cursor is already at the edge of the screen, this has no effect | ||
<a name="module_ansi-escape-sequences.format"></a> | ||
###ansi.format(str, effectArray) | ||
**Params** | ||
- str `string` - the string to format | ||
- effectArray `Array.<string>` - a list of sgr effects to add | ||
**Returns**: `string` | ||
<a name="module_ansi-escape-sequences.reset"></a> | ||
###ansi.reset | ||
remove all sgr effects | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.bold"></a> | ||
###ansi.bold | ||
Bold or increased intensity | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.italic"></a> | ||
###ansi.italic | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.underline"></a> | ||
###ansi.underline | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.imageNegative"></a> | ||
###ansi.imageNegative | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.fontDefault"></a> | ||
###ansi.fontDefault | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.font2"></a> | ||
###ansi.font2 | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.font3"></a> | ||
###ansi.font3 | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.font4"></a> | ||
###ansi.font4 | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.font5"></a> | ||
###ansi.font5 | ||
**Type**: `string` | ||
<a name="module_ansi-escape-sequences.font6"></a> | ||
###ansi.font6 | ||
**Type**: `string` |
var test = require("tape"); | ||
var lib = require("../"); | ||
var ansi = require("../"); | ||
test("first", function(t){ | ||
test("format", function(t){ | ||
t.equal(ansi.format("clive", ["red", "underline"]), "\u001b[31;4mclive\u001b[0m"); | ||
t.end(); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7980
9
132
87
2