fix spec and docs

This commit is contained in:
deepak1556 2016-06-09 10:38:45 +05:30
parent b91217f29e
commit 4749e18fc0
4 changed files with 18 additions and 24 deletions

View file

@ -3,6 +3,7 @@ const electron = require('electron')
const bindings = process.atomBinding('session')
const PERSIST_PREFIX = 'persist:'
const Session = new EventEmitter()
// Wrapper of binding.fromPartition that checks for ready event.
const fromPartition = function (partition, persist) {
@ -14,7 +15,7 @@ const fromPartition = function (partition, persist) {
}
// Returns the Session from |partition| string.
exports.fromPartition = function (partition = '') {
Session.fromPartition = function (partition = '') {
if (partition === '') return exports.defaultSession
if (partition.startsWith(PERSIST_PREFIX)) {
@ -25,7 +26,7 @@ exports.fromPartition = function (partition = '') {
}
// Returns the default session.
Object.defineProperty(exports, 'defaultSession', {
Object.defineProperty(Session, 'defaultSession', {
enumerable: true,
get: function () {
return fromPartition('', false)
@ -35,7 +36,9 @@ Object.defineProperty(exports, 'defaultSession', {
const wrapSession = function (session) {
// Session is an EventEmitter.
Object.setPrototypeOf(session, EventEmitter.prototype)
process.emit('session-created', session)
Session.emit('session-created', session)
}
bindings._setWrapSession(wrapSession)
module.exports = Session