Kaynağa Gözat

remove Path.getFromArray

Evan You 11 yıl önce
ebeveyn
işleme
4f81663fae
2 değiştirilmiş dosya ile 0 ekleme ve 26 silme
  1. 0 15
      src/parse/path.js
  2. 0 11
      test/unit/specs/parse/path_spec.js

+ 0 - 15
src/parse/path.js

@@ -272,21 +272,6 @@ exports.get = function (obj, path) {
   }
 }
 
-/**
- * Get from an object from an array
- *
- * @param {Object} obj
- * @param {Array} path
- */
-
-exports.getFromArray = function (obj, path) {
-  for (var i = 0, l = path.length; i < l; i++) {
-    if (obj == null) return
-    obj = obj[path[i]]
-  }
-  return obj
-}
-
 /**
  * Get from an object from an Observer-delimitered path.
  * e.g. "a\bb\bc"

+ 0 - 11
test/unit/specs/parse/path_spec.js

@@ -84,17 +84,6 @@ describe('Path', function () {
     expect(Path.get(obj, 'a.c')).toBeUndefined()
   })
 
-  it('get from Array', function () {
-    var path = ['a','b','0']
-    var obj = {
-      a: {
-        b: [123]
-      }
-    }
-    expect(Path.getFromArray(obj, path)).toBe(123)
-    expect(Path.getFromArray(obj, ['a','c','d'])).toBeUndefined()
-  })
-
   it('get from observer delimited path', function () {
     var delim = Observer.pathDelimiter
     var path = ['a','b','0'].join(delim)