剩余模块:生产入库,销售出库
This commit is contained in:
8
node_modules/parenthesis/LICENSE
generated
vendored
Normal file
8
node_modules/parenthesis/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
The MIT License (MIT)
|
||||
Copyright © 2016 Dmitry Ivanov
|
||||
|
||||
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.
|
||||
56
node_modules/parenthesis/README.md
generated
vendored
Normal file
56
node_modules/parenthesis/README.md
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
# parenthesis [](https://travis-ci.org/dy/parenthesis)
|
||||
|
||||
Parse parentheses from a string, return folded arrays.
|
||||
|
||||
[](https://npmjs.org/package/parenthesis/)
|
||||
|
||||
|
||||
```js
|
||||
var parse = require('parenthesis')
|
||||
|
||||
// Parse into nested format
|
||||
parse('a(b[c{d}])')
|
||||
// ['a(', ['b[', ['c{', ['d'], '}'], ']'], ')']
|
||||
|
||||
// Parse into flat format with cross-references
|
||||
parse('a(b[c{d}])', {
|
||||
brackets: ['()'],
|
||||
escape: '\\',
|
||||
flat: true
|
||||
})
|
||||
// ['a(\\1)', 'b[c{d}]']
|
||||
|
||||
|
||||
// Stringify nested format
|
||||
parse.stringify(['a(', ['b[', ['c{', ['d'], '}'], ']'], ')'])
|
||||
// 'a(b[c{d}])'
|
||||
|
||||
// Stringify flat format with cross-references
|
||||
parse.stringify(['a(\\1)', 'b[c{d}]'], {flat: true, escape: '\\'})
|
||||
// 'a(b[c{d}])'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### tokens = paren.parse(string, brackets|opts?)
|
||||
|
||||
Return array with tokens.
|
||||
|
||||
Option | Default | Meaning
|
||||
---|---|---
|
||||
`brackets` | `['{}', '[]', '()']` | Single brackets string or list of strings to detect brackets. Can be repeating brackets eg. `"" or ''`.
|
||||
`escape` | `'___'` | Escape prefix for flat references.
|
||||
`flat` | `false` | Return flat array instead of nested arrays.
|
||||
|
||||
### str = paren.stringify(tokens, {flat}?)
|
||||
|
||||
Stringify tokens back. Pass `{flat: true}` flag for flat tokens array.
|
||||
|
||||
## Related
|
||||
|
||||
* [balanced-match](http://npmjs.org/package/balanced-match)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
© 2018 Dmitry Yv. MIT License
|
||||
46
node_modules/parenthesis/index.d.ts
generated
vendored
Normal file
46
node_modules/parenthesis/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
declare module "parenthesis" {
|
||||
namespace parens {
|
||||
// One entry in the returned nested array
|
||||
type Node = string | ArrayTree;
|
||||
// A nested array of strings
|
||||
interface ArrayTree extends Array<Node> {}
|
||||
// Second-argument options used by the function
|
||||
interface Opts {
|
||||
// Single brackets string or list of strings to detect brackets. Can be repeating brackets eg. "" or ''.
|
||||
brackets?: string | string[],
|
||||
// Escape prefix for flat references.
|
||||
escape?: string,
|
||||
// `flat` is a boolean but since it affects return type, it's explicitly specified below
|
||||
}
|
||||
|
||||
// Parse parentheses from a string, return folded arrays
|
||||
function parse(
|
||||
str: string,
|
||||
opts?: string | string[] | (parens.Opts & { flat?: false })
|
||||
): parens.ArrayTree;
|
||||
// Parse parentheses from a string, return flat array
|
||||
function parse(
|
||||
str: string,
|
||||
opts: (parens.Opts & { flat: true })
|
||||
): string[];
|
||||
|
||||
// Stringify tokens back. Pass {flat: true} flag for flat tokens array.
|
||||
function stringify(tokens: ArrayTree, opts?: {flat: boolean}): string;
|
||||
}
|
||||
|
||||
// Parse parentheses from a string, return folded arrays
|
||||
function parens(
|
||||
str: string,
|
||||
opts?: string | string[] | (parens.Opts & { flat?: false })
|
||||
): parens.ArrayTree;
|
||||
// Parse parentheses from a string, return flat array
|
||||
function parens(
|
||||
str: string,
|
||||
opts: (parens.Opts & { flat: true })
|
||||
): string[];
|
||||
function parens(tokens: parens.ArrayTree, opts?: {flat: boolean}): string;
|
||||
|
||||
// imports via `import paren from "parenthesis", can call the export
|
||||
// directly or use `paren.parse` / `paren.stringify`.
|
||||
export = parens;
|
||||
}
|
||||
135
node_modules/parenthesis/index.js
generated
vendored
Normal file
135
node_modules/parenthesis/index.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* @module parenthesis
|
||||
*/
|
||||
|
||||
function parse (str, opts) {
|
||||
// pretend non-string parsed per-se
|
||||
if (typeof str !== 'string') return [str]
|
||||
|
||||
var res = [str]
|
||||
|
||||
if (typeof opts === 'string' || Array.isArray(opts)) {
|
||||
opts = {brackets: opts}
|
||||
}
|
||||
else if (!opts) opts = {}
|
||||
|
||||
var brackets = opts.brackets ? (Array.isArray(opts.brackets) ? opts.brackets : [opts.brackets]) : ['{}', '[]', '()']
|
||||
|
||||
var escape = opts.escape || '___'
|
||||
|
||||
var flat = !!opts.flat
|
||||
|
||||
brackets.forEach(function (bracket) {
|
||||
// create parenthesis regex
|
||||
var pRE = new RegExp(['\\', bracket[0], '[^\\', bracket[0], '\\', bracket[1], ']*\\', bracket[1]].join(''))
|
||||
|
||||
var ids = []
|
||||
|
||||
function replaceToken(token, idx, str){
|
||||
// save token to res
|
||||
var refId = res.push(token.slice(bracket[0].length, -bracket[1].length)) - 1
|
||||
|
||||
ids.push(refId)
|
||||
|
||||
return escape + refId + escape
|
||||
}
|
||||
|
||||
res.forEach(function (str, i) {
|
||||
var prevStr
|
||||
|
||||
// replace paren tokens till there’s none
|
||||
var a = 0
|
||||
while (str != prevStr) {
|
||||
prevStr = str
|
||||
str = str.replace(pRE, replaceToken)
|
||||
if (a++ > 10e3) throw Error('References have circular dependency. Please, check them.')
|
||||
}
|
||||
|
||||
res[i] = str
|
||||
})
|
||||
|
||||
// wrap found refs to brackets
|
||||
ids = ids.reverse()
|
||||
res = res.map(function (str) {
|
||||
ids.forEach(function (id) {
|
||||
str = str.replace(new RegExp('(\\' + escape + id + '\\' + escape + ')', 'g'), bracket[0] + '$1' + bracket[1])
|
||||
})
|
||||
return str
|
||||
})
|
||||
})
|
||||
|
||||
var re = new RegExp('\\' + escape + '([0-9]+)' + '\\' + escape)
|
||||
|
||||
// transform references to tree
|
||||
function nest (str, refs, escape) {
|
||||
var res = [], match
|
||||
|
||||
var a = 0
|
||||
while (match = re.exec(str)) {
|
||||
if (a++ > 10e3) throw Error('Circular references in parenthesis')
|
||||
|
||||
res.push(str.slice(0, match.index))
|
||||
|
||||
res.push(nest(refs[match[1]], refs))
|
||||
|
||||
str = str.slice(match.index + match[0].length)
|
||||
}
|
||||
|
||||
res.push(str)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
return flat ? res : nest(res[0], res)
|
||||
}
|
||||
|
||||
function stringify (arg, opts) {
|
||||
if (opts && opts.flat) {
|
||||
var escape = opts && opts.escape || '___'
|
||||
|
||||
var str = arg[0], prevStr
|
||||
|
||||
// pretend bad string stringified with no parentheses
|
||||
if (!str) return ''
|
||||
|
||||
|
||||
var re = new RegExp('\\' + escape + '([0-9]+)' + '\\' + escape)
|
||||
|
||||
var a = 0
|
||||
while (str != prevStr) {
|
||||
if (a++ > 10e3) throw Error('Circular references in ' + arg)
|
||||
prevStr = str
|
||||
str = str.replace(re, replaceRef)
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
return arg.reduce(function f (prev, curr) {
|
||||
if (Array.isArray(curr)) {
|
||||
curr = curr.reduce(f, '')
|
||||
}
|
||||
return prev + curr
|
||||
}, '')
|
||||
|
||||
function replaceRef(match, idx){
|
||||
if (arg[idx] == null) throw Error('Reference ' + idx + 'is undefined')
|
||||
return arg[idx]
|
||||
}
|
||||
}
|
||||
|
||||
function parenthesis (arg, opts) {
|
||||
if (Array.isArray(arg)) {
|
||||
return stringify(arg, opts)
|
||||
}
|
||||
else {
|
||||
return parse(arg, opts)
|
||||
}
|
||||
}
|
||||
|
||||
parenthesis.parse = parse
|
||||
parenthesis.stringify = stringify
|
||||
|
||||
module.exports = parenthesis
|
||||
46
node_modules/parenthesis/package.json
generated
vendored
Normal file
46
node_modules/parenthesis/package.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "parenthesis",
|
||||
"version": "3.1.8",
|
||||
"description": "Parse parentheses from a string",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node test.js",
|
||||
"test:browser": "budo test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dy/parenthesis.git"
|
||||
},
|
||||
"keywords": [
|
||||
"paren",
|
||||
"parenthesis",
|
||||
"parse",
|
||||
"brackets",
|
||||
"parser",
|
||||
"regexp",
|
||||
"stringify",
|
||||
"tokenizer",
|
||||
"replace",
|
||||
"csv",
|
||||
"string"
|
||||
],
|
||||
"author": {
|
||||
"name": "Dmitry Yv",
|
||||
"email": "df.creative@gmail.com",
|
||||
"url": "http://github.com/dy"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/dy/parenthesis/issues"
|
||||
},
|
||||
"homepage": "https://github.com/dy/parenthesis",
|
||||
"devDependencies": {
|
||||
"tape": "^4.9.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"types": "index.d.ts"
|
||||
}
|
||||
Reference in New Issue
Block a user