feat: promisify cookies api (#16464)
* feat: promisify the Cookie API * chore: update specs to test promisified cookies * chore: add deprecate wrapper for cookie callback API * docs: update docs to cookie promise changes * chore: remove redundant namespace use * docs: improve cookie example * docs: restore docs for cookie callback API * chore: restore cookie callback tests * fix: syntax of cookie promise return types
This commit is contained in:
parent
e2516dc808
commit
8396a2d504
8 changed files with 384 additions and 220 deletions
|
@ -2,7 +2,22 @@
|
|||
|
||||
const { EventEmitter } = require('events')
|
||||
const { app, deprecate } = require('electron')
|
||||
const { fromPartition, Session, Cookies } = process.atomBinding('session')
|
||||
const { Session, Cookies } = process.atomBinding('session')
|
||||
const realFromPartition = process.atomBinding('session').fromPartition
|
||||
|
||||
const wrappedSymbol = Symbol('wrapped-deprecate')
|
||||
const fromPartition = (partition) => {
|
||||
const session = realFromPartition(partition)
|
||||
if (!session[wrappedSymbol]) {
|
||||
session[wrappedSymbol] = true
|
||||
const { cookies } = session
|
||||
cookies.flushStore = deprecate.promisify(cookies.flushStore, 0)
|
||||
cookies.get = deprecate.promisify(cookies.get, 1)
|
||||
cookies.remove = deprecate.promisify(cookies.remove, 2)
|
||||
cookies.set = deprecate.promisify(cookies.set, 1)
|
||||
}
|
||||
return session
|
||||
}
|
||||
|
||||
// Public API.
|
||||
Object.defineProperties(exports, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue