first commit
This commit is contained in:
30
build/node_modules/lpad-align/cli.js
generated
vendored
Executable file
30
build/node_modules/lpad-align/cli.js
generated
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
var getStdin = require('get-stdin');
|
||||
var meow = require('meow');
|
||||
var lpadAlign = require('./');
|
||||
|
||||
var cli = meow({
|
||||
help: [
|
||||
'Usage',
|
||||
' $ cat <file> | lpad-align',
|
||||
'',
|
||||
'Example',
|
||||
' $ cat unicorn.txt | lpad-align',
|
||||
' foo',
|
||||
' foobar',
|
||||
' foobarcat'
|
||||
]
|
||||
}, {
|
||||
default: {
|
||||
indent: 4
|
||||
}
|
||||
});
|
||||
|
||||
getStdin(function (data) {
|
||||
var arr = data.split(/\r?\n/);
|
||||
|
||||
arr.forEach(function (el) {
|
||||
console.log(lpadAlign(el, arr, cli.flags.indent));
|
||||
});
|
||||
});
|
||||
17
build/node_modules/lpad-align/index.js
generated
vendored
Normal file
17
build/node_modules/lpad-align/index.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
var indentString = require('indent-string');
|
||||
var longest = require('longest');
|
||||
|
||||
module.exports = function (str, arr, indent) {
|
||||
var pad = typeof indent === 'number' ? indent : 0;
|
||||
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('Expected a `string`, got `' + typeof str + '`');
|
||||
}
|
||||
|
||||
if (!Array.isArray(arr)) {
|
||||
throw new TypeError('Expected an `Array`, got `' + typeof arr + '`');
|
||||
}
|
||||
|
||||
return indentString(str, ' ', pad + longest(arr).length - str.length);
|
||||
};
|
||||
21
build/node_modules/lpad-align/license
generated
vendored
Normal file
21
build/node_modules/lpad-align/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
75
build/node_modules/lpad-align/package.json
generated
vendored
Normal file
75
build/node_modules/lpad-align/package.json
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"lpad-align@1.1.2",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "lpad-align@1.1.2",
|
||||
"_id": "lpad-align@1.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-IfYArBwwlcPG5JfuZyce4ISB/p4=",
|
||||
"_location": "/lpad-align",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "lpad-align@1.1.2",
|
||||
"name": "lpad-align",
|
||||
"escapedName": "lpad-align",
|
||||
"rawSpec": "1.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/squeak"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/lpad-align/-/lpad-align-1.1.2.tgz",
|
||||
"_spec": "1.1.2",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "https://github.com/kevva"
|
||||
},
|
||||
"bin": {
|
||||
"lpad-align": "cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kevva/lpad-align/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"get-stdin": "^4.0.1",
|
||||
"indent-string": "^2.1.0",
|
||||
"longest": "^1.0.0",
|
||||
"meow": "^3.3.0"
|
||||
},
|
||||
"description": "Left pad a string to align with the longest string in an array",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"cli.js",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/kevva/lpad-align#readme",
|
||||
"keywords": [
|
||||
"align",
|
||||
"indent",
|
||||
"lpad"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "lpad-align",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/kevva/lpad-align.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "1.1.2"
|
||||
}
|
||||
80
build/node_modules/lpad-align/readme.md
generated
vendored
Normal file
80
build/node_modules/lpad-align/readme.md
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
# lpad-align [](https://travis-ci.org/kevva/lpad-align)
|
||||
|
||||
> Left pad a string to align with the longest string in an array
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save lpad-align
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const lpadAlign = require('lpad-align');
|
||||
|
||||
const words = [
|
||||
'foo',
|
||||
'foobar',
|
||||
'foobarcat'
|
||||
];
|
||||
|
||||
for (const x of words) {
|
||||
console.log(lpadAlign(x, words, 4));
|
||||
}
|
||||
|
||||
/*
|
||||
foo
|
||||
foobar
|
||||
foobarcat
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### lpadAlign(string, array, pad)
|
||||
|
||||
#### string
|
||||
|
||||
Type: `string`
|
||||
|
||||
String that will be padded.
|
||||
|
||||
#### array
|
||||
|
||||
Type: `Array`
|
||||
|
||||
Array to align against.
|
||||
|
||||
#### pad
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `4`
|
||||
|
||||
Indentation to prepend the string with.
|
||||
|
||||
|
||||
## CLI
|
||||
|
||||
```
|
||||
$ npm install --global lpad-align
|
||||
```
|
||||
|
||||
```
|
||||
Usage
|
||||
$ cat <file> | lpad-align
|
||||
|
||||
Example
|
||||
$ cat unicorn.txt | lpad-align
|
||||
foo
|
||||
foobar
|
||||
foobarcat
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Kevin Mårtensson](https://github.com/kevva)
|
||||
Reference in New Issue
Block a user