Add session module

This commit is contained in:
Cheng Zhao 2015-11-19 20:47:11 +08:00
parent b9ddb0c268
commit 47d7d49d19
5 changed files with 22 additions and 7 deletions

View file

@ -0,0 +1,17 @@
{EventEmitter} = require 'events'
bindings = process.atomBinding 'session'
PERSIST_PERFIX = 'persist:'
exports.fromPartition = (partition='') ->
if partition.startsWith PERSIST_PERFIX
bindings.fromPartition partition.substr(PERSIST_PERFIX.length), false
else
bindings.fromPartition partition, true
wrapSession = (session) ->
# session is an EventEmitter.
session.__proto__ = EventEmitter.prototype
bindings._setWrapSession wrapSession