本文整理汇总了TypeScript中bluebird.resolve函数的典型用法代码示例。如果您正苦于以下问题:TypeScript resolve函数的具体用法?TypeScript resolve怎么用?TypeScript resolve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolve函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: expect
.then(() => {
expect(getState().persistenceQueue.count()).to.eql(1)
stub.returns(Promise.resolve())
dispatch(createStickyAction({x: 1, y: 2, body: 'some other sticky', uuid: 'some uuid'}))
expect(getState().persistenceQueue.count()).to.eql(2)
stub.reset()
stub.returns(Promise.resolve())
})
示例2: filterByStigmas
filterByStigmas(stigma: string) {
if (stigma && stigma !== 'all') {
return Promise.resolve(this.$filter('filterWhoHasStigma')(this.data, stigma))
.then((data: Array<Object>) => {
this.data = data;
});
}
return Promise.resolve();
}
示例3: postImportRoutine
function postImportRoutine(db) {
if (db.sequelize.dialect.name === 'postgres') {
return Promise.resolve(_.toArray(db.models))
.map(model => {
return updatePostgresSequence(model, db);
});
}
return Promise.resolve(null);
}
示例4: findBy
public findBy(by: Object): Promise<Token | null> {
if ((by as any).token === "test" || (by as any).token === "testexpired") {
return Promise.resolve({
createdDate: moment(new Date()).subtract({days: 1}).toDate(),
expiredDate: moment(new Date()).add({days: 1}).toDate(),
token: "test",
user: {},
} as any);
} else {
return Promise.resolve(null);
}
}
示例5: PouchDB
.catch(function (error: any) {
if (error && error.error && error.name == 'indexed_db_went_bad') {
// we are in private mode...
console.log('private mode...')
inMemory = true;
_db = new PouchDB("pxt-" + pxt.storage.storageId(), { adapter: 'memory' })
return Promise.resolve(_db);
} else {
_db = temp;
return Promise.resolve(_db);
}
})
示例6: makeCookieAuthPromise
private makeCookieAuthPromise() {
if (this.authType !== 'cookie') return Bluebird.resolve();
return Bluebird.resolve().then(() => {
return this.client.post(this.compositeUri({prefix: '', uri: '/login.action'}))
.type('form')
.send({ os_username: this.username, os_password: this.password })
.then(o => o.body)
.catch(e => {
throw new Error('CookieAuth has failed');
});
});
}
示例7: parseObdString
/**
* Parses an OBD output into useful data for developers
* @param {String} str
* @return {Object}
*/
function parseObdString (str: string) : Promise<OBDOutput|null> {
log('parsing command string %s', str);
let bytes = getByteGroupings(str);
let ret:OBDOutput = {
ts: new Date(),
bytes: str,
value: null,
pretty: null
};
if (!isHex(str)) {
log(
'received generic (non hex) string output "%s", not parsing',
str
);
return Promise.resolve(ret);
} else if (bytes && bytes[0] === OBD_OUTPUT_MESSAGE_TYPES.MODE_01) {
log(
'received valid output "%s" of type "%s", parsing',
str,
OBD_OUTPUT_MESSAGE_TYPES.MODE_01
);
let pidCode: string = bytes[1];
let pid:PID|null = pids.getPidByPidCode(pidCode);
if (pid) {
log(`we have a matching class for code "${pidCode}"`);
// We have a class that knows how to deal with this pid output. Parse it!
ret.pretty = pid.getFormattedValueForBytes(bytes);
// pass all bytes returned and have the particular PID figure it out
ret.value = pid.getValueForBytes(bytes.slice(0));
ret.name = pid.getName();
ret.pid = pid.getPid()
return Promise.resolve(ret);
} else {
log('no match found for pid %s', pidCode);
// Emit the data, but just the raw bytes
return Promise.resolve(ret);
}
} else {
// Wasn't a recognised message type - was probably our own bytes
// since the serial module outputs those as "data" for some reason
return Promise.resolve(null);
}
}
示例8: getResourceBufferPromise
export function getResourceBufferPromise(resource:ReadableStream|Buffer|string):Promise<Buffer> {
// might be a string
if (typeof resource === 'string') {
return Promise.resolve(new Buffer(resource));
}
// might already be a Buffer
if (resource instanceof Buffer) {
return Promise.resolve(resource);
}
// probably a stream
// TODO npe/type check
return this.streamPromise(resource);
}
示例9: exec
exec(
visitedNamespaceTbl?: { [key: string]: Namespace },
state?: any
): Promise<Output[]> {
var doc = this.doc;
var namespace = doc.namespace;
if(state) this.state = state;
if(!visitedNamespaceTbl) visitedNamespaceTbl = {};
visitedNamespaceTbl[namespace.id] = namespace;
return(Promise.resolve(this.prepare()).then((output: Output) => Promise.map(
namespace.getUsedImportList(),
(namespace: Namespace) => {
if(!visitedNamespaceTbl[namespace.id]) {
if(namespace.doc) {
var transform = new this.construct(namespace.doc);
return(transform.exec(visitedNamespaceTbl, this.state));
}
}
return([]);
}
).then((outputList: Output[][]) => Array.prototype.concat.apply([output], outputList))));
}
示例10:
.then((task) => {
if (task) {
return vol.unassignTask();
} else {
return Promise.resolve();
}
})