Convert all source files to JavaScript
This commit is contained in:
parent
403870a27e
commit
1f9691ae13
144 changed files with 11211 additions and 7301 deletions
42
atom/browser/api/lib/session.js
Normal file
42
atom/browser/api/lib/session.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
var EventEmitter, PERSIST_PERFIX, bindings, wrapSession;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
bindings = process.atomBinding('session');
|
||||
|
||||
PERSIST_PERFIX = 'persist:';
|
||||
|
||||
|
||||
/* Returns the Session from |partition| string. */
|
||||
|
||||
exports.fromPartition = function(partition) {
|
||||
if (partition == null) {
|
||||
partition = '';
|
||||
}
|
||||
if (partition === '') {
|
||||
return exports.defaultSession;
|
||||
}
|
||||
if (partition.startsWith(PERSIST_PERFIX)) {
|
||||
return bindings.fromPartition(partition.substr(PERSIST_PERFIX.length), false);
|
||||
} else {
|
||||
return bindings.fromPartition(partition, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Returns the default session. */
|
||||
|
||||
Object.defineProperty(exports, 'defaultSession', {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return bindings.fromPartition('', false);
|
||||
}
|
||||
});
|
||||
|
||||
wrapSession = function(session) {
|
||||
|
||||
/* session is an EventEmitter. */
|
||||
return session.__proto__ = EventEmitter.prototype;
|
||||
};
|
||||
|
||||
bindings._setWrapSession(wrapSession);
|
Loading…
Add table
Add a link
Reference in a new issue