yacoordinate 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export declare class Coordinate {
5
5
  static distance(coorArr: [Coordinate, Coordinate]): number;
6
6
  add(value: number, dimension?: number): Coordinate;
7
7
  clone(): Coordinate;
8
+ project(n: number): Coordinate;
8
9
  }
package/index.js CHANGED
@@ -32,6 +32,15 @@ class Coordinate {
32
32
  clone() {
33
33
  return new Coordinate(this.coordinate.slice());
34
34
  }
35
+ project(n) {
36
+ let coor = this.clone();
37
+ for (let i = 0; i < n; i++) {
38
+ if (i > coor.coordinate.length)
39
+ throw new Error("length < n");
40
+ coor.coordinate.pop();
41
+ }
42
+ return coor;
43
+ }
35
44
  }
36
45
  exports.Coordinate = Coordinate;
37
46
  const a = new Coordinate([0, 0, 0]);
package/index.ts CHANGED
@@ -24,6 +24,11 @@ export class Coordinate {
24
24
  clone(){
25
25
  return new Coordinate(this.coordinate.slice());
26
26
  }
27
+ project(n:number){
28
+ let coor = this.clone();
29
+ coor.coordinate.slice(0, -2);
30
+ return coor;
31
+ }
27
32
  }
28
33
  const a = new Coordinate([0, 0, 0]);
29
34
  const b = new Coordinate([3, 4, 0]);
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
- {
2
- "name": "yacoordinate",
3
- "version": "1.0.1",
4
- "description": "A coordinate library can use any dimensions",
5
- "license": "MIT",
6
- "author": "yangycl",
7
- "type": "module",
8
- "main": "index.js",
9
- "types": "./index.d.ts",
10
- "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1"
12
- }
13
- }
1
+ {
2
+ "name": "yacoordinate",
3
+ "version": "1.0.2",
4
+ "description": "A coordinate library can use any dimensions",
5
+ "license": "MIT",
6
+ "author": "yangycl",
7
+ "type": "module",
8
+ "main": "index.js",
9
+ "types": "./index.d.ts",
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/yangycl/ya-coordinate.git"
16
+ }
17
+ }