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:
Charles Kerr 2019-01-25 12:11:35 -06:00 committed by GitHub
parent e2516dc808
commit 8396a2d504
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 384 additions and 220 deletions

View file

@ -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, {