escape-code
Advanced tools
Comparing version 0.0.1 to 0.0.2
26
index.js
'use strict'; | ||
module.exports = EscapeCode; | ||
var Delegator = require('delegates'); | ||
@@ -9,9 +10,30 @@ function EscapeCode(str) { | ||
String.call(this, str); | ||
this._stringValue = str; | ||
Object.defineProperty(this, '_stringValue', { | ||
value: str | ||
}); | ||
} | ||
var ecp = EscapeCode.prototype = new String(); // jshint ignore:line | ||
var ecp = EscapeCode.prototype; | ||
ecp.isEscapeCode = true; | ||
ecp.toString = ecp.valueOf = function() { | ||
return this._stringValue; | ||
}; | ||
new Delegator(ecp, '_stringValue') | ||
.method('charAt') | ||
.method('charCodeAt') | ||
.method('concat') | ||
.method('indexOf') | ||
.method('lastIndexOf') | ||
.method('match') | ||
.method('replace') | ||
.method('search') | ||
.method('slice') | ||
.method('split') | ||
.method('substr') | ||
.method('substring') | ||
.method('toLowerCase') | ||
.method('toUpperCase') | ||
.method('trim'); |
{ | ||
"name": "escape-code", | ||
"version": "0.0.1", | ||
"description": "My ace module", | ||
"version": "0.0.2", | ||
"description": "ANSI Escape Code as an object", | ||
"license": "MIT", | ||
@@ -26,6 +26,6 @@ "repository": "jamestalmage/escape-code", | ||
], | ||
"keywords": [ | ||
"" | ||
], | ||
"dependencies": {}, | ||
"keywords": [], | ||
"dependencies": { | ||
"delegates": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
@@ -32,0 +32,0 @@ "codeclimate-test-reporter": "^0.1.0", |
# escape-code | ||
Ansi Escape Code as an object | ||
ANSI Escape Code as an object | ||
@@ -27,6 +27,5 @@ [![Build Status](https://travis-ci.org/jamestalmage/escape-code.svg?branch=master)](https://travis-ci.org/jamestalmage/escape-code) | ||
assert(code instanceof EscapeCode); | ||
// or | ||
assert(code.isEscapeCode); // boolean value === true | ||
// it extends String | ||
assert(code instanceof String); | ||
// toString just returns what you put in. | ||
@@ -45,5 +44,24 @@ assert.equal(code.toString(), '\u001b[32m'); | ||
Each instance has the following delegate methods that will be called on the | ||
underlying String. | ||
- charAt | ||
- charCodeAt | ||
- concat | ||
- indexOf | ||
- lastIndexOf | ||
- match | ||
- replace | ||
- search | ||
- slice | ||
- split | ||
- substr | ||
- substring | ||
- toLowerCase | ||
- toUpperCase | ||
- trim | ||
## License | ||
MIT © [James Talmage](http://github.com/jamestalmage) |
4869
33
66
1
+ Addeddelegates@^0.1.0
+ Addeddelegates@0.1.0(transitive)