• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript deepcopy.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中deepcopy.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: if

) => new Promise<any>(async (resolve, reject) => {
	const opts = options || {
		includeSecret: false,
		includeProfileImageIds: false
	};

	let _app: any;

	// Populate the app if 'app' is ID
	if (mongo.ObjectID.prototype.isPrototypeOf(app)) {
		_app = await App.findOne({
			_id: app
		});
	} else if (typeof app === 'string') {
		_app = await User.findOne({
			_id: new mongo.ObjectID(app)
		});
	} else {
		_app = deepcopy(app);
	}

	// Me
	if (me && !mongo.ObjectID.prototype.isPrototypeOf(me)) {
		if (typeof me === 'string') {
			me = new mongo.ObjectID(me);
		} else {
			me = me._id;
		}
	}

	// Rename _id to id
	_app.id = _app._id;
	delete _app._id;

	delete _app.name_id_lower;

	// Visible by only owner
	if (!opts.includeSecret) {
		delete _app.secret;
	}

	_app.icon_url = _app.icon != null
		? `${config.drive_url}/${_app.icon}`
		: `${config.drive_url}/app-default.jpg`;

	if (me) {
		// 既に連携しているか
		const exist = await Userkey.count({
			app_id: _app.id,
			user_id: me,
		}, {
			limit: 1
		});

		_app.is_authorized = exist === 1;
	}

	resolve(_app);
});
开发者ID:syuilo,项目名称:misskey-core,代码行数:59,代码来源:app.ts


示例2: if

export const pack = (notification: any) => new Promise<any>(async (resolve, reject) => {
	let _notification: any;

	// Populate the notification if 'notification' is ID
	if (mongo.ObjectID.prototype.isPrototypeOf(notification)) {
		_notification = await Notification.findOne({
			_id: notification
		});
	} else if (typeof notification === 'string') {
		_notification = await Notification.findOne({
			_id: new mongo.ObjectID(notification)
		});
	} else {
		_notification = deepcopy(notification);
	}

	// Rename _id to id
	_notification.id = _notification._id;
	delete _notification._id;

	// Rename notifierId to userId
	_notification.userId = _notification.notifierId;
	delete _notification.notifierId;

	const me = _notification.notifieeId;
	delete _notification.notifieeId;

	// Populate notifier
	_notification.user = await packUser(_notification.userId, me);

	switch (_notification.type) {
		case 'follow':
		case 'receiveFollowRequest':
			// nope
			break;
		case 'mention':
		case 'reply':
		case 'renote':
		case 'quote':
		case 'reaction':
		case 'poll_vote':
			// Populate note
			_notification.note = await packNote(_notification.noteId, me);
			break;
		default:
			console.error(`Unknown type: ${_notification.type}`);
			break;
	}

	resolve(_notification);
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:51,代码来源:notification.ts


示例3: if

) => new Promise<Object>(async (resolve, reject) => {
	const opts = options || {
		includeParent: false
	};

	let _folder: any;

	// Populate the folder if 'folder' is ID
	if (mongo.ObjectID.prototype.isPrototypeOf(folder)) {
		_folder = await DriveFolder.findOne({_id: folder});
	} else if (typeof folder === 'string') {
		_folder = await DriveFolder.findOne({_id: new mongo.ObjectID(folder)});
	} else {
		_folder = deepcopy(folder);
	}

	// Rename _id to id
	_folder.id = _folder._id;
	delete _folder._id;

	if (opts.includeParent && _folder.parent_id) {
		// Populate parent folder
		_folder.parent = await self(_folder.parent_id, {
			includeParent: true
		});
	}

	resolve(_folder);
});
开发者ID:syuilo,项目名称:misskey-core,代码行数:29,代码来源:drive-folder.ts


示例4: normalizeLibExtension

  return pkg.libExtensions.map( ext => {
    normalizeLibExtension(ext);

    const meta: PackageMetadata = deepcopy(pkg);

    meta.parent = pkg;
    meta.extension = ext;

    meta.name = meta.name + titleCamelCase(ext.name);
    meta.umd = meta.umd + '-' + ext.name;
    meta.dirName = ext.name;
    meta.dir = meta.dir + '/' + ext.dir;
    meta.moduleName = meta.moduleName + '.' + voca.camelCase(ext.name);

    meta.externals.push(meta.parent.dir);
    meta.externalsWebpack.push(getExternalsWebpack(meta.dir)[0]);


    // TODO: remove object 'ext', only string... move everything to local package.json of extension
    meta.entry = ext.entry;
    if (meta.entry.indexOf('.') > -1) {
      meta.entry = meta.entry.substr(0, meta.entry.lastIndexOf('.'));
    }

    tsConfigUpdate(meta.tsConfigObj, meta);
    tryRunHook(meta.dir, 'tsconfig', meta.tsConfigObj);

    normalizeTsConfig(meta);

    meta.libExtensions = undefined;

    return meta;
  });
开发者ID:shlomiassaf,项目名称:ng2-chess,代码行数:33,代码来源:config.ts


示例5: if

) => new Promise<any>(async (resolve, reject) => {
	let _reaction: any;

	// Populate the reaction if 'reaction' is ID
	if (mongo.ObjectID.prototype.isPrototypeOf(reaction)) {
		_reaction = await Reaction.findOne({
			_id: reaction
		});
	} else if (typeof reaction === 'string') {
		_reaction = await Reaction.findOne({
			_id: new mongo.ObjectID(reaction)
		});
	} else {
		_reaction = deepcopy(reaction);
	}

	// Rename _id to id
	_reaction.id = _reaction._id;
	delete _reaction._id;

	// Populate user
	_reaction.user = await packUser(_reaction.userId, me);

	resolve(_reaction);
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:25,代码来源:note-reaction.ts


示例6: if

) => new Promise<any>(async (resolve, reject) => {
	let _request: any;

	// Populate the request if 'request' is ID
	if (mongo.ObjectID.prototype.isPrototypeOf(request)) {
		_request = await FollowRequest.findOne({
			_id: request
		});
	} else if (typeof request === 'string') {
		_request = await FollowRequest.findOne({
			_id: new mongo.ObjectID(request)
		});
	} else {
		_request = deepcopy(request);
	}

	// Rename _id to id
	_request.id = _request._id;
	delete _request._id;

	// Populate follower
	_request.follower = await packUser(_request.followerId, me);

	// Populate followee
	_request.followee = await packUser(_request.followeeId, me);

	resolve(_request);
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:28,代码来源:follow-request.ts


示例7: if

) => new Promise<any>(async (resolve, reject) => {
	let _favorite: any;

	// Populate the favorite if 'favorite' is ID
	if (mongo.ObjectID.prototype.isPrototypeOf(favorite)) {
		_favorite = await Favorite.findOne({
			_id: favorite
		});
	} else if (typeof favorite === 'string') {
		_favorite = await Favorite.findOne({
			_id: new mongo.ObjectID(favorite)
		});
	} else {
		_favorite = deepcopy(favorite);
	}

	// Rename _id to id
	_favorite.id = _favorite._id;
	delete _favorite._id;

	// Populate note
	_favorite.note = await packNote(_favorite.noteId, me);

	resolve(_favorite);
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:25,代码来源:favorite.ts


示例8: serializeDriveTag

) => new Promise<any>(async (resolve, reject) => {
	const opts = Object.assign({
		detail: false
	}, options);

	let _file: any;

	// Populate the file if 'file' is ID
	if (mongo.ObjectID.prototype.isPrototypeOf(file)) {
		_file = await DriveFile.findOne({
			_id: file
		});
	} else if (typeof file === 'string') {
		_file = await DriveFile.findOne({
			_id: new mongo.ObjectID(file)
		});
	} else {
		_file = deepcopy(file);
	}

	if (!_file) return reject('invalid file arg.');

	// rendered target
	let _target: any = {};

	_target.id = _file._id;
	_target.createdAt = _file.uploadDate;
	_target.name = _file.filename;
	_target.type = _file.contentType;
	_target.datasize = _file.length;
	_target.md5 = _file.md5;

	_target = Object.assign(_target, _file.metadata);

	_target.url = _file.metadata.url ? _file.metadata.url : `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}`;
	_target.thumbnailUrl = _file.metadata.thumbnailUrl ? _file.metadata.thumbnailUrl : _file.metadata.url ? _file.metadata.url : `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}?thumbnail`;
	_target.isRemote = _file.metadata.isRemote;

	if (_target.properties == null) _target.properties = {};

	if (opts.detail) {
		if (_target.folderId) {
			// Populate folder
			_target.folder = await packFolder(_target.folderId, {
				detail: true
			});
		}

		/*
		if (_target.tags) {
			// Populate tags
			_target.tags = await _target.tags.map(async (tag: any) =>
				await serializeDriveTag(tag)
			);
		}
		*/
	}

	resolve(_target);
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:60,代码来源:drive-file.ts


示例9: deepcopy

) => new Promise<Object>(async (resolve, reject) => {

	const _record = deepcopy(record);

	// Rename _id to id
	_record.id = _record._id;
	delete _record._id;

	resolve(_record);
});
开发者ID:syuilo,项目名称:misskey-core,代码行数:10,代码来源:signin.ts


示例10: if

) => new Promise<any>(async (resolve, reject) => {
	const opts = Object.assign({
		detail: true
	}, options);

	let _game: any;

	// Populate the game if 'game' is ID
	if (mongo.ObjectID.prototype.isPrototypeOf(game)) {
		_game = await ReversiGame.findOne({
			_id: game
		});
	} else if (typeof game === 'string') {
		_game = await ReversiGame.findOne({
			_id: new mongo.ObjectID(game)
		});
	} else {
		_game = deepcopy(game);
	}

	// Me
	const meId: mongo.ObjectID = me
		? mongo.ObjectID.prototype.isPrototypeOf(me)
			? me as mongo.ObjectID
			: typeof me === 'string'
				? new mongo.ObjectID(me)
				: (me as IUser)._id
		: null;

	// Rename _id to id
	_game.id = _game._id;
	delete _game._id;

	if (opts.detail === false) {
		delete _game.logs;
		delete _game.settings.map;
	} else {
		// 互換性のため
		if (_game.settings.map.hasOwnProperty('size')) {
			_game.settings.map = _game.settings.map.data.match(new RegExp(`.{1,${_game.settings.map.size}}`, 'g'));
		}
	}

	// Populate user
	_game.user1 = await packUser(_game.user1Id, meId);
	_game.user2 = await packUser(_game.user2Id, meId);
	if (_game.winnerId) {
		_game.winner = await packUser(_game.winnerId, meId);
	} else {
		_game.winner = null;
	}

	resolve(_game);
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:54,代码来源:game.ts



注:本文中的deepcopy.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript deeplearn.oneHot函数代码示例发布时间:2022-05-25
下一篇:
TypeScript deep-freeze-node.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap