added unit testing, and started implementing unit tests...phew

This commit is contained in:
Josh Burman
2019-03-12 22:28:02 -04:00
parent 74aad4a957
commit e8c2539f1b
3489 changed files with 464813 additions and 88 deletions

14
node_modules/wide-align/LICENSE generated vendored Normal file
View File

@ -0,0 +1,14 @@
Copyright (c) 2015, Rebecca Turner <me@re-becca.org>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

47
node_modules/wide-align/README.md generated vendored Normal file
View File

@ -0,0 +1,47 @@
wide-align
----------
A wide-character aware text alignment function for use in terminals / on the
console.
### Usage
```
var align = require('wide-align')
// Note that if you view this on a unicode console, all of the slashes are
// aligned. This is because on a console, all narrow characters are
// an en wide and all wide characters are an em. In browsers, this isn't
// held to and wide characters like "古" can be less than two narrow
// characters even with a fixed width font.
console.log(align.center('abc', 10)) // ' abc '
console.log(align.center('古古古', 10)) // ' 古古古 '
console.log(align.left('abc', 10)) // 'abc '
console.log(align.left('古古古', 10)) // '古古古 '
console.log(align.right('abc', 10)) // ' abc'
console.log(align.right('古古古', 10)) // ' 古古古'
```
### Functions
#### `align.center(str, length)` → `str`
Returns *str* with spaces added to both sides such that that it is *length*
chars long and centered in the spaces.
#### `align.left(str, length)` → `str`
Returns *str* with spaces to the right such that it is *length* chars long.
### `align.right(str, length)` → `str`
Returns *str* with spaces to the left such that it is *length* chars long.
### Origins
These functions were originally taken from
[cliui](https://npmjs.com/package/cliui). Changes include switching to the
MUCH faster pad generation function from
[lodash](https://npmjs.com/package/lodash), making center alignment pad
both sides and adding left alignment.

65
node_modules/wide-align/align.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
'use strict'
var stringWidth = require('string-width')
exports.center = alignCenter
exports.left = alignLeft
exports.right = alignRight
// lodash's way of generating pad characters.
function createPadding (width) {
var result = ''
var string = ' '
var n = width
do {
if (n % 2) {
result += string;
}
n = Math.floor(n / 2);
string += string;
} while (n);
return result;
}
function alignLeft (str, width) {
var trimmed = str.trimRight()
if (trimmed.length === 0 && str.length >= width) return str
var padding = ''
var strWidth = stringWidth(trimmed)
if (strWidth < width) {
padding = createPadding(width - strWidth)
}
return trimmed + padding
}
function alignRight (str, width) {
var trimmed = str.trimLeft()
if (trimmed.length === 0 && str.length >= width) return str
var padding = ''
var strWidth = stringWidth(trimmed)
if (strWidth < width) {
padding = createPadding(width - strWidth)
}
return padding + trimmed
}
function alignCenter (str, width) {
var trimmed = str.trim()
if (trimmed.length === 0 && str.length >= width) return str
var padLeft = ''
var padRight = ''
var strWidth = stringWidth(trimmed)
if (strWidth < width) {
var padLeftBy = parseInt((width - strWidth) / 2, 10)
padLeft = createPadding(padLeftBy)
padRight = createPadding(width - (strWidth + padLeftBy))
}
return padLeft + trimmed + padRight
}

66
node_modules/wide-align/package.json generated vendored Normal file
View File

@ -0,0 +1,66 @@
{
"_from": "wide-align@1.1.3",
"_id": "wide-align@1.1.3",
"_inBundle": false,
"_integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==",
"_location": "/wide-align",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "wide-align@1.1.3",
"name": "wide-align",
"escapedName": "wide-align",
"rawSpec": "1.1.3",
"saveSpec": null,
"fetchSpec": "1.1.3"
},
"_requiredBy": [
"/mocha"
],
"_resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz",
"_shasum": "ae074e6bdc0c14a431e804e624549c633b000457",
"_spec": "wide-align@1.1.3",
"_where": "/Users/josh.burman/Projects/braid/node_modules/mocha",
"author": {
"name": "Rebecca Turner",
"email": "me@re-becca.org",
"url": "http://re-becca.org/"
},
"bugs": {
"url": "https://github.com/iarna/wide-align/issues"
},
"bundleDependencies": false,
"dependencies": {
"string-width": "^1.0.2 || 2"
},
"deprecated": false,
"description": "A wide-character aware text alignment function for use on the console or with fixed width fonts.",
"devDependencies": {
"tap": "10 || 11 || 12"
},
"files": [
"align.js"
],
"homepage": "https://github.com/iarna/wide-align#readme",
"keywords": [
"wide",
"double",
"unicode",
"cjkv",
"pad",
"align"
],
"license": "ISC",
"main": "align.js",
"name": "wide-align",
"repository": {
"type": "git",
"url": "git+https://github.com/iarna/wide-align.git"
},
"scripts": {
"test": "tap --coverage test/*.js",
"version": "perl -pi -e 's/^( \"version\": $ENV{npm_config_node_version}\").*?\",/$1abc\",/' package-lock.json ; git add package-lock.json"
},
"version": "1.1.3"
}