Passing '' to fromPartiion should return default partition

This commit is contained in:
Cheng Zhao 2015-12-12 15:47:15 +08:00
parent 56c1f04a51
commit 10cad5d9ec

View file

@ -6,6 +6,7 @@ PERSIST_PERFIX = 'persist:'
# Returns the Session from |partition| string. # Returns the Session from |partition| string.
exports.fromPartition = (partition='') -> exports.fromPartition = (partition='') ->
return exports.defaultSession if partition is ''
if partition.startsWith PERSIST_PERFIX if partition.startsWith PERSIST_PERFIX
bindings.fromPartition partition.substr(PERSIST_PERFIX.length), false bindings.fromPartition partition.substr(PERSIST_PERFIX.length), false
else else
@ -14,7 +15,7 @@ exports.fromPartition = (partition='') ->
# Returns the default session. # Returns the default session.
Object.defineProperty exports, 'defaultSession', Object.defineProperty exports, 'defaultSession',
enumerable: true enumerable: true
get: -> exports.fromPartition 'persist:' get: -> bindings.fromPartition '', false
wrapSession = (session) -> wrapSession = (session) ->
# session is an EventEmitter. # session is an EventEmitter.