Kaynağa Gözat

move where some util functions live

Adam Shaw 7 yıl önce
ebeveyn
işleme
6cfa20a8b6

+ 1 - 1
src/reducers/event-mutation.ts

@@ -4,7 +4,7 @@ import { diffDayAndTime } from '../datelib/marker'
 import { Duration, createDuration } from '../datelib/duration'
 import { EventStore, EventDef, EventInstance } from './event-store'
 import { assignTo } from '../util/object'
-import { filterHash } from './utils'
+import { filterHash } from '../util/object'
 import Calendar from '../Calendar'
 
 export interface EventMutation {

+ 2 - 1
src/reducers/event-store.ts

@@ -1,7 +1,8 @@
 import UnzonedRange from '../models/UnzonedRange'
 import { DateInput } from '../datelib/env'
 import Calendar from '../Calendar'
-import { filterHash, parseClassName, refineProps, ClassNameInput } from './utils'
+import { filterHash } from '../util/object'
+import { parseClassName, refineProps, ClassNameInput } from './utils'
 import { expandRecurring } from './recurring-events'
 import { applyMutation } from './event-mutation'
 

+ 2 - 1
src/reducers/recurring-events.ts

@@ -2,7 +2,8 @@ import { startOfDay, addDays } from '../datelib/marker'
 import { Duration, createDuration } from '../datelib/duration'
 import UnzonedRange from '../models/UnzonedRange'
 import Calendar from '../Calendar'
-import { refineProps, arrayToHash } from './utils'
+import { arrayToHash } from '../util/object'
+import { refineProps } from './utils'
 import { EventInput } from './event-store'
 
 // types

+ 0 - 22
src/reducers/utils.ts

@@ -1,16 +1,4 @@
 
-export function filterHash(hash, func) {
-  let filtered = {}
-
-  for (let key in hash) {
-    if (func(hash[key], key)) {
-      filtered[key] = hash[key]
-    }
-  }
-
-  return filtered
-}
-
 export function refineProps(rawProps, processorFuncs, leftoverProps?): any {
   let refined = {}
 
@@ -46,13 +34,3 @@ export function parseClassName(raw: ClassNameInput) {
     return []
   }
 }
-
-export function arrayToHash(a) {
-  let hash = {}
-
-  for (let item of a) {
-    hash[item] = true
-  }
-
-  return hash
-}

+ 24 - 0
src/util/object.ts

@@ -88,3 +88,27 @@ export function mergeProps(propObjs, complexProps?): any {
 
   return dest
 }
+
+
+export function filterHash(hash, func) {
+  let filtered = {}
+
+  for (let key in hash) {
+    if (func(hash[key], key)) {
+      filtered[key] = hash[key]
+    }
+  }
+
+  return filtered
+}
+
+
+export function arrayToHash(a) {
+  let hash = {}
+
+  for (let item of a) {
+    hash[item] = true
+  }
+
+  return hash
+}