new Index() now accepts a computeHash() callback-ish.
This commit is contained in:
parent
cd582e2e3a
commit
0880787d68
@ -21,10 +21,10 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"babel-runtime": "^5",
|
||||
"lodash.bind": "^3.1.0",
|
||||
"lodash.callback": "^3.1.1",
|
||||
"lodash.foreach": "^3.0.2",
|
||||
"make-error": "^1.0.0"
|
||||
"lodash.bind": "^3",
|
||||
"lodash.callback": "^3",
|
||||
"lodash.foreach": "^3",
|
||||
"make-error": "^1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel": "^5",
|
||||
|
@ -1,4 +1,5 @@
|
||||
import bind from 'lodash.bind'
|
||||
import callback from 'lodash.callback'
|
||||
|
||||
import clearObject from './clear-object'
|
||||
import isEmpty from './is-empty'
|
||||
@ -7,7 +8,11 @@ import NotImplemented from './not-implemented'
|
||||
// ===================================================================
|
||||
|
||||
export default class Index {
|
||||
constructor () {
|
||||
constructor (computeHash) {
|
||||
if (computeHash) {
|
||||
this.computeHash = callback(computeHash)
|
||||
}
|
||||
|
||||
this._itemsByHash = Object.create(null)
|
||||
this._keysToHash = Object.create(null)
|
||||
|
||||
|
@ -57,8 +57,7 @@ describe('Index', function () {
|
||||
col.add(item)
|
||||
})
|
||||
|
||||
byGroup = new Index()
|
||||
byGroup.computeHash = item => item.group
|
||||
byGroup = new Index('group')
|
||||
|
||||
col.createIndex('byGroup', byGroup)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user