本文整理汇总了TypeScript中ms.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: default
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');
// Get 'offset' parameter
const [offset = 0, offsetErr] = $.num.optional.min(0).get(params.offset);
if (offsetErr) return rej('invalid offset param');
// ID list of the user itself and other users who the user follows
const followingIds = await getFriendIds(me._id);
// ミュートしているユーザーを取得
const mutedUserIds = (await Mute.find({
muterId: me._id
})).map(m => m.muteeId);
const users = await User
.find({
_id: {
$nin: followingIds.concat(mutedUserIds)
},
isLocked: false,
$or: [{
lastUsedAt: {
$gte: new Date(Date.now() - ms('7days'))
}
}, {
host: null
}]
}, {
limit: limit,
skip: offset,
sort: {
followersCount: -1
}
});
// Serialize
res(await Promise.all(users.map(async user =>
await pack(user, me, { detail: true }))));
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:42,代码来源:recommendation.ts
示例2: ms
import Note, { INote, isValidText, isValidCw, pack } from '../../../../models/note';
import User, { ILocalUser, IUser } from '../../../../models/user';
import DriveFile, { IDriveFile } from '../../../../models/drive-file';
import create from '../../../../services/note/create';
import { IApp } from '../../../../models/app';
import getParams from '../../get-params';
export const meta = {
desc: {
ja: '投稿します。'
},
requireCredential: true,
limit: {
duration: ms('1hour'),
max: 300,
minInterval: ms('1second')
},
kind: 'note-write',
params: {
visibility: $.str.optional.or(['public', 'home', 'followers', 'specified', 'private']).note({
default: 'public',
desc: {
ja: '投稿の公開範囲'
}
}),
visibleUserIds: $.arr($.type(ID)).optional.unique().min(1).note({
开发者ID:ha-dai,项目名称:Misskey,代码行数:31,代码来源:create.ts
示例3: require
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
const ms = require('ms');
import User, { pack, ILocalUser } from '../../../../models/user';
import Following from '../../../../models/following';
import deleteFollowing from '../../../../services/following/delete';
export const meta = {
desc: {
ja: '指定したユーザーのフォローを解除します。',
en: 'Unfollow a user.'
},
limit: {
duration: ms('1hour'),
max: 100
},
requireCredential: true,
kind: 'following-write'
};
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');
// Check if the followee is yourself
if (user._id.equals(userId)) {
开发者ID:ha-dai,项目名称:Misskey,代码行数:31,代码来源:delete.ts
示例4: ms
import * as sdk from 'botpress/sdk'
import { validate } from 'joi'
import ms from 'ms'
import ConfusionEngine from './confusion-engine'
import ScopedEngine from './engine'
import { EngineByBot } from './typings'
import { EntityDefCreateSchema, IntentDefCreateSchema } from './validation'
import _ from 'lodash'
const SYNC_INTERVAL_MS = ms('15s')
export default async (bp: typeof sdk, nlus: EngineByBot) => {
const router = bp.http.createRouterForBot('nlu')
const syncByBots: { [key: string]: NodeJS.Timer } = {}
const scheduleSyncNLU = (botId: string) => {
if (syncByBots[botId]) {
clearTimeout(syncByBots[botId])
delete syncByBots[botId]
}
syncByBots[botId] = setTimeout(() => {
delete syncByBots[botId]
const botEngine = nlus[botId] as ScopedEngine
syncNLU(botEngine, false)
}, SYNC_INTERVAL_MS)
}
const syncNLU = async (botEngine: ScopedEngine, confusionMode: boolean = false): Promise<string> => {
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:31,代码来源:api.ts
示例5: default
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');
// Get 'offset' parameter
const [offset = 0, offsetErr] = $.num.optional.min(0).get(params.offset);
if (offsetErr) return rej('invalid offset param');
// Get 'reply' parameter
const [reply, replyErr] = $.bool.optional.get(params.reply);
if (replyErr) return rej('invalid reply param');
// Get 'renote' parameter
const [renote, renoteErr] = $.bool.optional.get(params.renote);
if (renoteErr) return rej('invalid renote param');
// Get 'media' parameter
const [media, mediaErr] = $.bool.optional.get(params.media);
if (mediaErr) return rej('invalid media param');
// Get 'poll' parameter
const [poll, pollErr] = $.bool.optional.get(params.poll);
if (pollErr) return rej('invalid poll param');
const query = {
_id: { $gte: new Date(Date.now() - ms('1days')) },
renoteCount: { $gt: 0 },
'_user.host': null
} as any;
if (reply != undefined) {
query.replyId = reply ? { $exists: true, $ne: null } : null;
}
if (renote != undefined) {
query.renoteId = renote ? { $exists: true, $ne: null } : null;
}
if (media != undefined) {
query.mediaIds = media ? { $exists: true, $ne: null } : null;
}
if (poll != undefined) {
query.poll = poll ? { $exists: true, $ne: null } : null;
}
// Issue query
const notes = await Note
.find(query, {
limit: limit,
skip: offset,
sort: {
renoteCount: -1,
_id: -1
}
});
// Serialize
res(await Promise.all(notes.map(async note =>
await pack(note, user, { detail: true }))));
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:62,代码来源:trend.ts
示例6: Promise
return new Promise(async (resolve, reject) => {
const payload = {
value:
{
user: {
displayName: user.displayName,
email: user.email,
name: user.name,
tenant: user.tenant
},
scopes: user.scopes
}
};
let options = { issuer: this.issuer.value, expiresIn: this.tokenExpiration.value };
try {
let jwtToken = this.createToken(payload, options);
let renewToken = this.createToken({}, options);
let expiresIn;
if (typeof this.tokenExpiration.value === 'string') {
const milliseconds = ms(this.tokenExpiration.value);
expiresIn = Math.floor(milliseconds / 1000);
}
else {
expiresIn = this.tokenExpiration.value;
}
// token payload contains iat (absolute expiration date in sec)
resolve({ expiresIn, token: jwtToken, renewToken: renewToken });
}
catch (err) {
reject({ error: err, message: "Error when creating new token for user :" + user.name + " - " + (err.message || err) });
}
});
开发者ID:workfel,项目名称:vulcain-corejs,代码行数:35,代码来源:tokenService.ts
示例7: ms
export const groupEntriesByTime = (entries: MonitoringStats[], timeInterval: string) => {
if (!entries || !entries.length) {
return
}
const timeInMs = ms(timeInterval)
let groupTime = entries[0].ts
return _.groupBy(entries, entry => {
return entry.ts - groupTime <= timeInMs ? groupTime : (groupTime = entry.ts)
}) as MonitoringGroupInterval
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:12,代码来源:monitoring.ts
示例8: getOrCreateRecentConversation
async getOrCreateRecentConversation(botId: string, userId: string, { originatesFromUserMessage = false } = {}) {
// TODO: Lifetime config by bot
const config = await this.bp.config.getModuleConfigForBot('channel-web', botId)
const recentCondition = this.knex.date.isAfter(
'last_heard_on',
moment()
.subtract(ms(config.recentConversationLifetime), 'ms')
.toDate()
)
const conversation = await this.knex('web_conversations')
.select('id')
.whereNotNull('last_heard_on')
.andWhere({ userId, botId })
.andWhere(recentCondition)
.orderBy('last_heard_on', 'desc')
.limit(1)
.then()
.get(0)
return conversation ? conversation.id : this.createConversation(botId, userId, { originatesFromUserMessage })
}
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:23,代码来源:db.ts
注:本文中的ms.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论