本文整理汇总了TypeScript中cuid.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: handleErrors
sock.on('canvas:create', handleErrors(authCheck(async (req: Protocol.CreateCanvasRequest, cb: Protocol.Callback<Protocol.CreateCanvasResponse>) => {
const id = cuid();
await dbConn.createCanvas(id);
cb({
success: true,
id
});
})));
示例2: cuid
(title: string) => ({
type: ADD_TODO,
payload: {
id: cuid(),
title: title,
completed: false,
},
})
示例3: cuid
.concatMap((action) => { // action is type: { type: "ADD_TODO"; payload: string; }
const toast = { id: cuid(), text: action.payload.title };
const addToast$ = Observable.of(toastsActions.addToast(toast));
const removeToast$ = Observable.of(toastsActions.removeToast(toast.id))
.delay(TOAST_LIFETIME);
return addToast$.concat(removeToast$);
});
示例4: addDocument
/**
* Adds a Page object to the internal index.
*
* @param {Page} page
* @returns {Promise<IndexingReport>}
*/
public addDocument(page: Page): Promise<IndexingReport> {
this.index.addDoc({
id: page.id,
title: page.title,
info: page.info,
url: page.url
});
return Promise.resolve(
{
id: cuid(),
docId: page.id,
succeeded: true,
timeStamp: new Date().toString()
} as IndexingReport);
}
示例5: escapeFormField
app.post( '/api/subscribe', (req, resp, done) => {
let info = {
name: escapeFormField( req.body.name ),
email: escapeFormField( req.body.email ),
origin: escapeFormField( req.body.origin ),
lang: escapeFormField( req.body.lang ),
type: escapeFormField( req.body.type ),
id: cuid()
};
fs.appendFile('subscribers.txt', JSON.stringify( info )+',\n', function (err) {
sendMail( "book-sample-request.pt.html", info, (err) => {
if ( !err ) {
resp.status(200).json({success: "Email sent"});
} else {
resp.status(500).json({message: "Unable to send email:", error: err });
}
done();
} )
});
} );
示例6: generateToken
export function generateToken () {
const token = cuid().substr(1) + cuid().substr(1) // substr: get rid of the starting `c`
return token.toUpperCase()
}
示例7: cuid
_.forOwn(iterable, (value, key) => {
result.push({key: key, value: value, id: cuid() });
});
示例8: generateToken
public static generateToken() {
const token = cuid().substr(1) + cuid().substr(1) // substr: get rid of the starting `c`
return token.toUpperCase()
}