Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 16a2fd7

Browse files
committedFeb 7, 2019
Appease linter
1 parent 8263817 commit 16a2fd7

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed
 

‎src/index.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Ptr, { InvalidPtrError, EvalError } from "./index";
1+
import Ptr, { EvalError, InvalidPtrError } from "./index";
22

33
describe("Ptr", () => {
44
describe("parse", () => {
@@ -8,16 +8,16 @@ describe("Ptr", () => {
88
// https://tools.ietf.org/html/rfc6901#section-5
99
const cases = {
1010
"": [],
11-
"/foo": ["foo"],
12-
"/foo/0": ["foo", "0"],
1311
"/": [""],
12+
"/ ": [" "],
1413
"/a~1b": ["a/b"],
1514
"/c%d": ["c%d"],
1615
"/e^f": ["e^f"],
16+
"/foo": ["foo"],
17+
"/foo/0": ["foo", "0"],
1718
"/g|h": ["g|h"],
1819
"/i\\j": ["i\\j"],
1920
"/k\"l": ["k\"l"],
20-
"/ ": [" "],
2121
"/m~0n": ["m~n"],
2222
"/o~0~1p/q~1~0r": ["o~/p", "q/~r"],
2323
};
@@ -50,9 +50,9 @@ describe("Ptr", () => {
5050
});
5151

5252
it("returns an error when an instance lacks a property", () => {
53-
expect(() => { Ptr.parse("/foo").eval(3.14) }).toThrow(new EvalError(3.14, "foo"));
54-
expect(() => { Ptr.parse("/0").eval([]) }).toThrow(new EvalError([], "0"));
55-
expect(() => { Ptr.parse("/foo").eval({}) }).toThrow(new EvalError({}, "foo"));
53+
expect(() => { Ptr.parse("/foo").eval(3.14); }).toThrow(new EvalError(3.14, "foo"));
54+
expect(() => { Ptr.parse("/0").eval([]); }).toThrow(new EvalError([], "0"));
55+
expect(() => { Ptr.parse("/foo").eval({}); }).toThrow(new EvalError({}, "foo"));
5656
});
5757
});
5858
});

‎src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
export default class Ptr {
2-
public tokens: string[];
3-
4-
constructor(tokens: string[]) {
5-
this.tokens = tokens;
6-
}
7-
82
public static parse(s: string): Ptr {
93
// From the ABNF syntax of JSON Pointer, the only valid initial character
104
// for a JSON Pointer is "/". Empty strings are acceptable.
@@ -21,17 +15,23 @@ export default class Ptr {
2115
}
2216

2317
const [, ...tokens] = s.split("/");
24-
return new Ptr(tokens.map(token => {
18+
return new Ptr(tokens.map((token) => {
2519
return token.replace("~1", "/").replace("~0", "~");
2620
}));
2721
}
2822

23+
public tokens: string[];
24+
25+
constructor(tokens: string[]) {
26+
this.tokens = tokens;
27+
}
28+
2929
public toString(): string {
3030
if (this.tokens.length === 0) {
3131
return "";
3232
}
3333

34-
const tokens = this.tokens.map(token => {
34+
const tokens = this.tokens.map((token) => {
3535
return token.replace("~", "~0").replace("/", "~1");
3636
});
3737

‎tslint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"interface-name": [
99
true,
1010
"never-prefix"
11-
]
11+
],
12+
"max-classes-per-file": false
1213
},
1314
"rulesDirectory": [],
1415
"files": [

0 commit comments

Comments
 (0)
Please sign in to comment.