Skip to content

Commit e010d12

Browse files
author
Maier, Martin
committed
* removed Extract constaint to avoid conflicts with minor typescript versions
1 parent 6d11acf commit e010d12

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
"chai": "^4.1.0",
4646
"mocha": "^5.2.0",
4747
"ts-node": "^3.3.0",
48-
"typescript": "^2.9.1"
48+
"typescript": "^2.9.2"
4949
}
5050
}

src/replicator.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import {deepFreeze, isDeepFrozen} from './deepFreeze'
88
* Warns if source object is just frozen, not deep frozen
99
**/
1010
export class ReplicationBuilder<T> {
11-
private replica: T = null
12-
private freeze = false
11+
private replica: T = null;
12+
private freeze = false;
1313

1414
/**
1515
* default constructor
1616
* @param {RT} sourceObject traversing object
1717
*/
1818
private constructor(sourceObject: T) {
19-
this.replica = _.cloneDeep(sourceObject)
20-
this.freeze = Object.isFrozen(sourceObject)
19+
this.replica = _.cloneDeep(sourceObject);
20+
this.freeze = Object.isFrozen(sourceObject);
2121
if (this.freeze && !isDeepFrozen(sourceObject)) {
2222
console.warn('Source object is frozen but not deep frozen. Please care that always deepFreeze() is used to recursively freeze the object')
2323
}
@@ -31,12 +31,12 @@ export class ReplicationBuilder<T> {
3131
* @param {K} childNode of the root node
3232
* @returns {ReplicaChildOperator<T, T[K]>} operator of child node
3333
**/
34-
public getChild<K extends Extract<keyof T, string>>(childNode: K): ReplicaChildOperator<T, T[K]> {
35-
let node = this.replica[childNode]
34+
public getChild<K extends keyof T>(childNode: K): ReplicaChildOperator<T, T[K]> {
35+
let node = this.replica[childNode];
3636
return new ReplicaChildOperator((() => this.build()), this.replica, node, childNode)
3737
}
3838

39-
modify<K extends Extract<keyof T, string>>(childNode: K): PropertyModifier<ReplicationBuilder<T>, T[K]> {
39+
modify<K extends keyof T>(childNode: K): PropertyModifier<ReplicationBuilder<T>, T[K]> {
4040
return new PropertyModifier<ReplicationBuilder<T>, T[K]>(this, childNode, this.replica)
4141
}
4242

@@ -65,14 +65,14 @@ export class ReplicationBuilder<T> {
6565
* Operator for nodes of the replica
6666
*/
6767
export class ReplicaChildOperator<RT, T> {
68-
private buildFunction: () => RT
69-
private node: T
68+
private buildFunction: () => RT;
69+
private node: T;
7070
private replica: RT;
7171
private relativePath;
7272

73-
constructor(buildFunction: () => RT, replica: RT, node: T, relativePath: string) {
74-
this.buildFunction = buildFunction
75-
this.node = node
73+
constructor(buildFunction: () => RT, replica: RT, node: T, relativePath: string | number | symbol) {
74+
this.buildFunction = buildFunction;
75+
this.node = node;
7676
this.replica = replica;
7777
this.relativePath = relativePath;
7878
}
@@ -82,7 +82,7 @@ export class ReplicaChildOperator<RT, T> {
8282
* @returns {ReplicaChildOperator<RT, N[K]>} traversable child node
8383
**/
8484
getChild<K extends keyof T>(childNode: K): ReplicaChildOperator<RT, T[K]> {
85-
let branch = this.node[childNode]
85+
let branch = this.node[childNode];
8686
return new ReplicaChildOperator(this.buildFunction, this.replica, branch, this.relativePath + '.' + childNode)
8787
}
8888

@@ -108,13 +108,13 @@ export class ReplicaChildOperator<RT, T> {
108108
}
109109

110110
export class PropertyModifier<PT, VT> {
111-
private replica: any
112-
private parent: PT
113-
private relativePathToRoot: string
111+
private replica: any;
112+
private parent: PT;
113+
private relativePathToRoot: string | number | symbol;
114114

115-
constructor(parent: PT, relativePathToRoot: string, rootObject: any) {
116-
this.replica = rootObject
117-
this.parent = parent
115+
constructor(parent: PT, relativePathToRoot: string | number | symbol, rootObject: any) {
116+
this.replica = rootObject;
117+
this.parent = parent;
118118
this.relativePathToRoot = relativePathToRoot
119119
}
120120

@@ -124,7 +124,7 @@ export class PropertyModifier<PT, VT> {
124124
* @returns {PT}
125125
*/
126126
to(value: VT): PT {
127-
_.set(this.replica, this.relativePathToRoot, value)
127+
_.set(this.replica, this.relativePathToRoot, value);
128128
return this.parent
129129
}
130130

@@ -134,8 +134,8 @@ export class PropertyModifier<PT, VT> {
134134
* @returns PT this
135135
*/
136136
by(setFunction: (VT) => VT): PT {
137-
let currentvalue = _.get(this.replica, this.relativePathToRoot)
138-
let value = setFunction(currentvalue)
137+
let currentvalue = _.get(this.replica, this.relativePathToRoot);
138+
let value = setFunction(currentvalue);
139139
return this.to(value)
140140
}
141141
}

0 commit comments

Comments
 (0)