mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
22
web/node_modules/stringify-object/LICENSE
generated
vendored
Normal file
22
web/node_modules/stringify-object/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
Copyright (c) 2015, Yeoman team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
131
web/node_modules/stringify-object/index.js
generated
vendored
Normal file
131
web/node_modules/stringify-object/index.js
generated
vendored
Normal file
|
@ -0,0 +1,131 @@
|
|||
'use strict';
|
||||
const isRegexp = require('is-regexp');
|
||||
const isObj = require('is-obj');
|
||||
const getOwnEnumPropSymbols = require('get-own-enumerable-property-symbols').default;
|
||||
|
||||
module.exports = (val, opts, pad) => {
|
||||
const seen = [];
|
||||
|
||||
return (function stringify(val, opts, pad) {
|
||||
opts = opts || {};
|
||||
opts.indent = opts.indent || '\t';
|
||||
pad = pad || '';
|
||||
|
||||
let tokens;
|
||||
|
||||
if (opts.inlineCharacterLimit === undefined) {
|
||||
tokens = {
|
||||
newLine: '\n',
|
||||
newLineOrSpace: '\n',
|
||||
pad,
|
||||
indent: pad + opts.indent
|
||||
};
|
||||
} else {
|
||||
tokens = {
|
||||
newLine: '@@__STRINGIFY_OBJECT_NEW_LINE__@@',
|
||||
newLineOrSpace: '@@__STRINGIFY_OBJECT_NEW_LINE_OR_SPACE__@@',
|
||||
pad: '@@__STRINGIFY_OBJECT_PAD__@@',
|
||||
indent: '@@__STRINGIFY_OBJECT_INDENT__@@'
|
||||
};
|
||||
}
|
||||
|
||||
const expandWhiteSpace = string => {
|
||||
if (opts.inlineCharacterLimit === undefined) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const oneLined = string
|
||||
.replace(new RegExp(tokens.newLine, 'g'), '')
|
||||
.replace(new RegExp(tokens.newLineOrSpace, 'g'), ' ')
|
||||
.replace(new RegExp(tokens.pad + '|' + tokens.indent, 'g'), '');
|
||||
|
||||
if (oneLined.length <= opts.inlineCharacterLimit) {
|
||||
return oneLined;
|
||||
}
|
||||
|
||||
return string
|
||||
.replace(new RegExp(tokens.newLine + '|' + tokens.newLineOrSpace, 'g'), '\n')
|
||||
.replace(new RegExp(tokens.pad, 'g'), pad)
|
||||
.replace(new RegExp(tokens.indent, 'g'), pad + opts.indent);
|
||||
};
|
||||
|
||||
if (seen.indexOf(val) !== -1) {
|
||||
return '"[Circular]"';
|
||||
}
|
||||
|
||||
if (val === null ||
|
||||
val === undefined ||
|
||||
typeof val === 'number' ||
|
||||
typeof val === 'boolean' ||
|
||||
typeof val === 'function' ||
|
||||
typeof val === 'symbol' ||
|
||||
isRegexp(val)) {
|
||||
return String(val);
|
||||
}
|
||||
|
||||
if (val instanceof Date) {
|
||||
return `new Date('${val.toISOString()}')`;
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) {
|
||||
if (val.length === 0) {
|
||||
return '[]';
|
||||
}
|
||||
|
||||
seen.push(val);
|
||||
|
||||
const ret = '[' + tokens.newLine + val.map((el, i) => {
|
||||
const eol = val.length - 1 === i ? tokens.newLine : ',' + tokens.newLineOrSpace;
|
||||
let value = stringify(el, opts, pad + opts.indent);
|
||||
if (opts.transform) {
|
||||
value = opts.transform(val, i, value);
|
||||
}
|
||||
return tokens.indent + value + eol;
|
||||
}).join('') + tokens.pad + ']';
|
||||
|
||||
seen.pop();
|
||||
|
||||
return expandWhiteSpace(ret);
|
||||
}
|
||||
|
||||
if (isObj(val)) {
|
||||
let objKeys = Object.keys(val).concat(getOwnEnumPropSymbols(val));
|
||||
|
||||
if (opts.filter) {
|
||||
objKeys = objKeys.filter(el => opts.filter(val, el));
|
||||
}
|
||||
|
||||
if (objKeys.length === 0) {
|
||||
return '{}';
|
||||
}
|
||||
|
||||
seen.push(val);
|
||||
|
||||
const ret = '{' + tokens.newLine + objKeys.map((el, i) => {
|
||||
const eol = objKeys.length - 1 === i ? tokens.newLine : ',' + tokens.newLineOrSpace;
|
||||
const isSymbol = typeof el === 'symbol';
|
||||
const isClassic = !isSymbol && /^[a-z$_][a-z$_0-9]*$/i.test(el);
|
||||
const key = isSymbol || isClassic ? el : stringify(el, opts);
|
||||
let value = stringify(val[el], opts, pad + opts.indent);
|
||||
if (opts.transform) {
|
||||
value = opts.transform(val, el, value);
|
||||
}
|
||||
return tokens.indent + String(key) + ': ' + value + eol;
|
||||
}).join('') + tokens.pad + '}';
|
||||
|
||||
seen.pop();
|
||||
|
||||
return expandWhiteSpace(ret);
|
||||
}
|
||||
|
||||
val = String(val).replace(/[\r\n]/g, x => x === '\n' ? '\\n' : '\\r');
|
||||
|
||||
if (opts.singleQuotes === false) {
|
||||
val = val.replace(/"/g, '\\"');
|
||||
return `"${val}"`;
|
||||
}
|
||||
|
||||
val = val.replace(/\\?'/g, '\\\'');
|
||||
return `'${val}'`;
|
||||
})(val, opts, pad);
|
||||
};
|
40
web/node_modules/stringify-object/package.json
generated
vendored
Normal file
40
web/node_modules/stringify-object/package.json
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "stringify-object",
|
||||
"version": "3.3.0",
|
||||
"description": "Stringify an object/array like JSON.stringify just without all the double-quotes",
|
||||
"license": "BSD-2-Clause",
|
||||
"repository": "yeoman/stringify-object",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"object",
|
||||
"stringify",
|
||||
"pretty",
|
||||
"print",
|
||||
"dump",
|
||||
"format",
|
||||
"type",
|
||||
"json"
|
||||
],
|
||||
"dependencies": {
|
||||
"get-own-enumerable-property-symbols": "^3.0.0",
|
||||
"is-obj": "^1.0.1",
|
||||
"is-regexp": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
155
web/node_modules/stringify-object/readme.md
generated
vendored
Normal file
155
web/node_modules/stringify-object/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,155 @@
|
|||
# stringify-object [](http://travis-ci.org/yeoman/stringify-object)
|
||||
|
||||
> Stringify an object/array like JSON.stringify just without all the double-quotes
|
||||
|
||||
Useful for when you want to get the string representation of an object in a formatted way.
|
||||
|
||||
It also handles circular references and lets you specify quote type.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install stringify-object
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const stringifyObject = require('stringify-object');
|
||||
|
||||
const obj = {
|
||||
foo: 'bar',
|
||||
'arr': [1, 2, 3],
|
||||
nested: { hello: "world" }
|
||||
};
|
||||
|
||||
const pretty = stringifyObject(obj, {
|
||||
indent: ' ',
|
||||
singleQuotes: false
|
||||
});
|
||||
|
||||
console.log(pretty);
|
||||
/*
|
||||
{
|
||||
foo: "bar",
|
||||
arr: [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
nested: {
|
||||
hello: "world"
|
||||
}
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### stringifyObject(input, [options])
|
||||
|
||||
Circular references will be replaced with `"[Circular]"`.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Object` `Array`
|
||||
|
||||
#### options
|
||||
|
||||
##### indent
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `\t`
|
||||
|
||||
Preferred indentation.
|
||||
|
||||
##### singleQuotes
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Set to false to get double-quoted strings.
|
||||
|
||||
##### filter(obj, prop)
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Expected to return a `boolean` of whether to include the property `prop` of the object `obj` in the output.
|
||||
|
||||
##### transform(obj, prop, originalResult)
|
||||
|
||||
Type: `Function`<br>
|
||||
Default: `undefined`
|
||||
|
||||
Expected to return a `string` that transforms the string that resulted from stringifying `obj[prop]`. This can be used to detect special types of objects that need to be stringified in a particular way. The `transform` function might return an alternate string in this case, otherwise returning the `originalResult`.
|
||||
|
||||
Here's an example that uses the `transform` option to mask fields named "password":
|
||||
|
||||
```js
|
||||
const obj = {
|
||||
user: 'becky',
|
||||
password: 'secret'
|
||||
}
|
||||
|
||||
const pretty = stringifyObject(obj, {
|
||||
transform: (obj, prop, originalResult) => {
|
||||
if (prop === 'password') {
|
||||
return originalResult.replace(/\w/g, '*');
|
||||
} else {
|
||||
return originalResult;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log(pretty);
|
||||
/*
|
||||
{
|
||||
user: 'becky',
|
||||
password: '******'
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
##### inlineCharacterLimit
|
||||
|
||||
Type: `number`
|
||||
|
||||
When set, will inline values up to `inlineCharacterLimit` length for the sake of more terse output.
|
||||
|
||||
For example, given the example at the top of the README:
|
||||
|
||||
```js
|
||||
const obj = {
|
||||
foo: 'bar',
|
||||
'arr': [1, 2, 3],
|
||||
nested: { hello: "world" }
|
||||
};
|
||||
|
||||
const pretty = stringifyObject(obj, {
|
||||
indent: ' ',
|
||||
singleQuotes: false,
|
||||
inlineCharacterLimit: 12
|
||||
});
|
||||
|
||||
console.log(pretty);
|
||||
/*
|
||||
{
|
||||
foo: "bar",
|
||||
arr: [1, 2, 3],
|
||||
nested: {
|
||||
hello: "world"
|
||||
}
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
As you can see, `arr` was printed as a one-liner because its string was shorter than 12 characters.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
BSD-2-Clause © Yeoman team
|
Loading…
Add table
Add a link
Reference in a new issue