Comparing version 0.1.20 to 0.1.21
@@ -18,3 +18,3 @@ import { Segments, Node, Pattern } from './types'; | ||
private parseString; | ||
concat: (...args: (string | number)[]) => Path; | ||
concat: (...args: any[]) => Path; | ||
slice: (start?: number, end?: number) => Path; | ||
@@ -21,0 +21,0 @@ push: (item: string | number) => this; |
@@ -146,3 +146,6 @@ "use strict"; | ||
} | ||
return Path.getPath((_a = _this.segments).concat.apply(_a, args)); | ||
var path = new Path(''); | ||
path.segments = (_a = _this.segments).concat.apply(_a, args.map(function (s) { return _this.parseString(s); })); | ||
path.entire = path.segments.join('.'); | ||
return path; | ||
}; | ||
@@ -153,3 +156,6 @@ this.slice = function (start, end) { | ||
} | ||
return Path.getPath(_this.segments.slice(start, end)); | ||
var path = new Path(''); | ||
path.segments = _this.segments.slice(start, end); | ||
path.entire = path.segments.join('.'); | ||
return path; | ||
}; | ||
@@ -160,4 +166,3 @@ this.push = function (item) { | ||
} | ||
item = _this.parseString(item); | ||
_this.segments.push(item); | ||
_this.segments.push(_this.parseString(item)); | ||
_this.entire = _this.segments.join('.'); | ||
@@ -414,2 +419,5 @@ return _this; | ||
} | ||
else if (source instanceof Path) { | ||
return source.segments; | ||
} | ||
return source; | ||
@@ -416,0 +424,0 @@ }; |
{ | ||
"name": "cool-path", | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"description": "Path Matcher/Getter/Setter for Object/Array", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -247,2 +247,4 @@ import { Parser } from './parser' | ||
} | ||
} else if (source instanceof Path) { | ||
return source.segments | ||
} | ||
@@ -252,7 +254,10 @@ return source | ||
concat = (...args: Array<string | number>) => { | ||
concat = (...args: any[]) => { | ||
if (this.isMatchPattern) { | ||
throw new Error(`${this.entire} cannot be concat`) | ||
} | ||
return Path.getPath(this.segments.concat(...args)) | ||
const path = new Path('') | ||
path.segments = this.segments.concat(...args.map(s => this.parseString(s))) | ||
path.entire = path.segments.join('.') | ||
return path | ||
} | ||
@@ -264,3 +269,6 @@ | ||
} | ||
return Path.getPath(this.segments.slice(start, end)) | ||
const path = new Path('') | ||
path.segments = this.segments.slice(start, end) | ||
path.entire = path.segments.join('.') | ||
return path | ||
} | ||
@@ -272,4 +280,3 @@ | ||
} | ||
item = this.parseString(item) | ||
this.segments.push(item) | ||
this.segments.push(this.parseString(item)) | ||
this.entire = this.segments.join('.') | ||
@@ -276,0 +283,0 @@ return this |
161810
5158