Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
solkimicreb committed Jan 22, 2019
1 parent 2320b20 commit 734bd8e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/builtIns/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { proxyToRaw, rawToProxy } from '../internals'

const hasOwnProperty = Object.prototype.hasOwnProperty

function findObservable(obj) {
function findObservable (obj) {
const observableObj = rawToProxy.get(obj)
if (hasRunningReaction() && typeof obj === 'object' && obj !== null) {
if (observableObj) {
Expand All @@ -19,7 +19,7 @@ function findObservable(obj) {
return observableObj || obj
}

function patchIterator(iterator, isEntries) {
function patchIterator (iterator, isEntries) {
const originalNext = iterator.next
iterator.next = () => {
let { done, value } = originalNext.call(iterator)
Expand All @@ -36,19 +36,19 @@ function patchIterator(iterator, isEntries) {
}

const instrumentations = {
has(key) {
has (key) {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
registerRunningReactionForOperation({ target, key, type: 'has' })
return proto.has.apply(target, arguments)
},
get(key) {
get (key) {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
registerRunningReactionForOperation({ target, key, type: 'get' })
return findObservable(proto.get.apply(target, arguments))
},
add(key) {
add (key) {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
const hadKey = proto.has.call(target, key)
Expand All @@ -59,7 +59,7 @@ const instrumentations = {
}
return result
},
set(key, value) {
set (key, value) {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
const hadKey = proto.has.call(target, key)
Expand All @@ -73,7 +73,7 @@ const instrumentations = {
}
return result
},
delete(key) {
delete (key) {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
const hadKey = proto.has.call(target, key)
Expand All @@ -85,7 +85,7 @@ const instrumentations = {
}
return result
},
clear() {
clear () {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
const hadItems = target.size !== 0
Expand All @@ -97,7 +97,7 @@ const instrumentations = {
}
return result
},
forEach(cb, ...args) {
forEach (cb, ...args) {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
registerRunningReactionForOperation({ target, type: 'iterate' })
Expand All @@ -106,34 +106,34 @@ const instrumentations = {
const wrappedCb = (value, ...rest) => cb(findObservable(value), ...rest)
return proto.forEach.call(target, wrappedCb, ...args)
},
keys() {
keys () {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
registerRunningReactionForOperation({ target, type: 'iterate' })
return proto.keys.apply(target, arguments)
},
values() {
values () {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
registerRunningReactionForOperation({ target, type: 'iterate' })
const iterator = proto.values.apply(target, arguments)
return patchIterator(iterator, false)
},
entries() {
entries () {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
registerRunningReactionForOperation({ target, type: 'iterate' })
const iterator = proto.entries.apply(target, arguments)
return patchIterator(iterator, true)
},
[Symbol.iterator]() {
[Symbol.iterator] () {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
registerRunningReactionForOperation({ target, type: 'iterate' })
const iterator = proto[Symbol.iterator].apply(target, arguments)
return patchIterator(iterator, target instanceof Map)
},
get size() {
get size () {
const target = proxyToRaw.get(this)
const proto = Reflect.getPrototypeOf(this)
registerRunningReactionForOperation({ target, type: 'iterate' })
Expand All @@ -142,7 +142,7 @@ const instrumentations = {
}

export default {
get(target, key, receiver) {
get (target, key, receiver) {
// instrument methods and property accessors to be reactive
target = hasOwnProperty.call(instrumentations, key)
? instrumentations
Expand Down
2 changes: 2 additions & 0 deletions tests/builtIns/Map.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-unused-expressions: 0, no-unused-vars: 0 */

import { expect } from 'chai'
import { observable, isObservable, observe, raw } from '@nx-js/observer-util'
import { spy } from '../utils'
Expand Down
2 changes: 2 additions & 0 deletions tests/builtIns/Set.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-unused-expressions: 0, no-unused-vars: 0 */

import { expect } from 'chai'
import { observable, isObservable, observe, raw } from '@nx-js/observer-util'
import { spy } from '../utils'
Expand Down
2 changes: 2 additions & 0 deletions tests/builtIns/WeakMap.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-unused-expressions: 0, no-unused-vars: 0 */

import { expect } from 'chai'
import { observable, isObservable, observe, raw } from '@nx-js/observer-util'
import { spy } from '../utils'
Expand Down

0 comments on commit 734bd8e

Please sign in to comment.