Adam Shaw 8 lat temu
rodzic
commit
790d437ff5

+ 5 - 2
src/exports.ts

@@ -25,10 +25,13 @@ export {
   compareByFieldSpec,
   flexibleCompare,
   log,
-  warn,
-  removeExact
+  warn
 } from './util'
 
+export {
+  removeExact
+} from './util/array'
+
 export {
   intersectRects
 } from './util/geom'

+ 1 - 1
src/models/EventManager.ts

@@ -1,4 +1,4 @@
-import { removeExact } from '../util'
+import { removeExact } from '../util/array'
 import EventPeriod from './EventPeriod'
 import ArrayEventSource from './event-source/ArrayEventSource'
 import EventSource from './event-source/EventSource'

+ 1 - 1
src/models/EventPeriod.ts

@@ -1,5 +1,5 @@
 import * as moment from 'moment'
-import { removeExact, removeMatching } from '../util'
+import { removeExact, removeMatching } from '../util/array'
 import { isEmptyObject } from '../util/object'
 import { default as EmitterMixin, EmitterInterface } from '../common/EmitterMixin'
 import UnzonedRange from './UnzonedRange'

+ 1 - 1
src/models/event-source/ArrayEventSource.ts

@@ -1,4 +1,4 @@
-import { removeMatching } from '../../util'
+import { removeMatching } from '../../util/array'
 import EventSource from './EventSource'
 import SingleEventDef from '../event/SingleEventDef'
 

+ 1 - 1
src/models/event/EventDefMutation.ts

@@ -1,4 +1,4 @@
-import { isArraysEqual } from '../../util'
+import { isArraysEqual } from '../../util/array'
 import EventDateProfile from './EventDateProfile'
 import EventDef from './EventDef'
 import EventDefDateMutation from './EventDefDateMutation'

+ 0 - 53
src/util.ts

@@ -304,59 +304,6 @@ export function applyAll(functions, thisObj, args) {
 }
 
 
-export function removeMatching(array, testFunc) {
-  let removeCnt = 0
-  let i = 0
-
-  while (i < array.length) {
-    if (testFunc(array[i])) { // truthy value means *remove*
-      array.splice(i, 1)
-      removeCnt++
-    } else {
-      i++
-    }
-  }
-
-  return removeCnt
-}
-
-
-export function removeExact(array, exactVal) {
-  let removeCnt = 0
-  let i = 0
-
-  while (i < array.length) {
-    if (array[i] === exactVal) {
-      array.splice(i, 1)
-      removeCnt++
-    } else {
-      i++
-    }
-  }
-
-  return removeCnt
-}
-
-
-export function isArraysEqual(a0, a1) {
-  let len = a0.length
-  let i
-
-  if (len == null || len !== a1.length) { // not array? or not same length?
-    return false
-  }
-
-  for (i = 0; i < len; i++) {
-    if (a0[i] !== a1[i]) {
-      return false
-    }
-  }
-
-  return true
-}
-
-
-
 export function firstDefined(...args) {
   for (let i = 0; i < args.length; i++) {
     if (args[i] !== undefined) {

+ 51 - 0
src/util/array.ts

@@ -0,0 +1,51 @@
+
+export function removeMatching(array, testFunc) {
+  let removeCnt = 0
+  let i = 0
+
+  while (i < array.length) {
+    if (testFunc(array[i])) { // truthy value means *remove*
+      array.splice(i, 1)
+      removeCnt++
+    } else {
+      i++
+    }
+  }
+
+  return removeCnt
+}
+
+
+export function removeExact(array, exactVal) {
+  let removeCnt = 0
+  let i = 0
+
+  while (i < array.length) {
+    if (array[i] === exactVal) {
+      array.splice(i, 1)
+      removeCnt++
+    } else {
+      i++
+    }
+  }
+
+  return removeCnt
+}
+
+
+export function isArraysEqual(a0, a1) {
+  let len = a0.length
+  let i
+
+  if (len == null || len !== a1.length) { // not array? or not same length?
+    return false
+  }
+
+  for (i = 0; i < len; i++) {
+    if (a0[i] !== a1[i]) {
+      return false
+    }
+  }
+
+  return true
+}