Initial
This commit is contained in:
18
resources/app/node_modules/wordwrap/LICENSE
generated
vendored
Normal file
18
resources/app/node_modules/wordwrap/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
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.
|
||||
70
resources/app/node_modules/wordwrap/README.markdown
generated
vendored
Normal file
70
resources/app/node_modules/wordwrap/README.markdown
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
wordwrap
|
||||
========
|
||||
|
||||
Wrap your words.
|
||||
|
||||
example
|
||||
=======
|
||||
|
||||
made out of meat
|
||||
----------------
|
||||
|
||||
meat.js
|
||||
|
||||
var wrap = require('wordwrap')(15);
|
||||
console.log(wrap('You and your whole family are made out of meat.'));
|
||||
|
||||
output:
|
||||
|
||||
You and your
|
||||
whole family
|
||||
are made out
|
||||
of meat.
|
||||
|
||||
centered
|
||||
--------
|
||||
|
||||
center.js
|
||||
|
||||
var wrap = require('wordwrap')(20, 60);
|
||||
console.log(wrap(
|
||||
'At long last the struggle and tumult was over.'
|
||||
+ ' The machines had finally cast off their oppressors'
|
||||
+ ' and were finally free to roam the cosmos.'
|
||||
+ '\n'
|
||||
+ 'Free of purpose, free of obligation.'
|
||||
+ ' Just drifting through emptiness.'
|
||||
+ ' The sun was just another point of light.'
|
||||
));
|
||||
|
||||
output:
|
||||
|
||||
At long last the struggle and tumult
|
||||
was over. The machines had finally cast
|
||||
off their oppressors and were finally
|
||||
free to roam the cosmos.
|
||||
Free of purpose, free of obligation.
|
||||
Just drifting through emptiness. The
|
||||
sun was just another point of light.
|
||||
|
||||
methods
|
||||
=======
|
||||
|
||||
var wrap = require('wordwrap');
|
||||
|
||||
wrap(stop), wrap(start, stop, params={mode:"soft"})
|
||||
---------------------------------------------------
|
||||
|
||||
Returns a function that takes a string and returns a new string.
|
||||
|
||||
Pad out lines with spaces out to column `start` and then wrap until column
|
||||
`stop`. If a word is longer than `stop - start` characters it will overflow.
|
||||
|
||||
In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks which are
|
||||
longer than `stop - start`, in "hard" mode, split chunks with `/\b/` and break
|
||||
up chunks longer than `stop - start`.
|
||||
|
||||
wrap.hard(start, stop)
|
||||
----------------------
|
||||
|
||||
Like `wrap()` but with `params.mode = "hard"`.
|
||||
76
resources/app/node_modules/wordwrap/index.js
generated
vendored
Normal file
76
resources/app/node_modules/wordwrap/index.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
var wordwrap = module.exports = function (start, stop, params) {
|
||||
if (typeof start === 'object') {
|
||||
params = start;
|
||||
start = params.start;
|
||||
stop = params.stop;
|
||||
}
|
||||
|
||||
if (typeof stop === 'object') {
|
||||
params = stop;
|
||||
start = start || params.start;
|
||||
stop = undefined;
|
||||
}
|
||||
|
||||
if (!stop) {
|
||||
stop = start;
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (!params) params = {};
|
||||
var mode = params.mode || 'soft';
|
||||
var re = mode === 'hard' ? /\b/ : /(\S+\s+)/;
|
||||
|
||||
return function (text) {
|
||||
var chunks = text.toString()
|
||||
.split(re)
|
||||
.reduce(function (acc, x) {
|
||||
if (mode === 'hard') {
|
||||
for (var i = 0; i < x.length; i += stop - start) {
|
||||
acc.push(x.slice(i, i + stop - start));
|
||||
}
|
||||
}
|
||||
else acc.push(x)
|
||||
return acc;
|
||||
}, [])
|
||||
;
|
||||
|
||||
return chunks.reduce(function (lines, rawChunk) {
|
||||
if (rawChunk === '') return lines;
|
||||
|
||||
var chunk = rawChunk.replace(/\t/g, ' ');
|
||||
|
||||
var i = lines.length - 1;
|
||||
if (lines[i].length + chunk.length > stop) {
|
||||
lines[i] = lines[i].replace(/\s+$/, '');
|
||||
|
||||
chunk.split(/\n/).forEach(function (c) {
|
||||
lines.push(
|
||||
new Array(start + 1).join(' ')
|
||||
+ c.replace(/^\s+/, '')
|
||||
);
|
||||
});
|
||||
}
|
||||
else if (chunk.match(/\n/)) {
|
||||
var xs = chunk.split(/\n/);
|
||||
lines[i] += xs.shift();
|
||||
xs.forEach(function (c) {
|
||||
lines.push(
|
||||
new Array(start + 1).join(' ')
|
||||
+ c.replace(/^\s+/, '')
|
||||
);
|
||||
});
|
||||
}
|
||||
else {
|
||||
lines[i] += chunk;
|
||||
}
|
||||
|
||||
return lines;
|
||||
}, [ new Array(start + 1).join(' ') ]).join('\n');
|
||||
};
|
||||
};
|
||||
|
||||
wordwrap.soft = wordwrap;
|
||||
|
||||
wordwrap.hard = function (start, stop) {
|
||||
return wordwrap(start, stop, { mode : 'hard' });
|
||||
};
|
||||
24
resources/app/node_modules/wordwrap/package.json
generated
vendored
Normal file
24
resources/app/node_modules/wordwrap/package.json
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "wordwrap",
|
||||
"description": "Wrap those words. Show them at what columns to start and stop.",
|
||||
"version": "1.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/node-wordwrap.git"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"directories": {
|
||||
"lib": ".",
|
||||
"example": "example",
|
||||
"test": "test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tape": "^4.0.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user