type stringclasses 7
values | content stringlengths 4 9.55k | repo stringlengths 7 96 | path stringlengths 4 178 | language stringclasses 1
value |
|---|---|---|---|---|
ArrowFunction |
(dir: string): CacheConfig => {
const publicFiles = path.join(dir, 'public')
const staticFiles = path.join(dir, 'static')
const staticPages = path.join(dir, 'static-pages')
const nextData = path.join(dir, '_next', 'data')
const nextStatic = path.join(dir, '_next', 'static')
return filterNonExistentPathKey... | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(invalidationPaths: string[]): string[] => {
const wildCardDirectories = invalidationPaths
.filter((invalidationPath) => invalidationPath.endsWith('/*'))
.map((invalidationPath) => invalidationPath.replace('/*', ''))
return invalidationPaths.filter((invalidationPath) => {
return !wildCardDirectories.s... | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(invalidationPath) => invalidationPath.endsWith('/*') | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(invalidationPath) => invalidationPath.replace('/*', '') | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(invalidationPath) => {
return !wildCardDirectories.some(
(wildCardDirectory) =>
invalidationPath.startsWith(wildCardDirectory) &&
invalidationPath !== `${wildCardDirectory}*` &&
invalidationPath !== `${wildCardDirectory}/*` &&
wildCardDirectory !== invalidationPath,
)
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(wildCardDirectory) =>
invalidationPath.startsWith(wildCardDirectory) &&
invalidationPath !== `${wildCardDirectory}*` &&
invalidationPath !== `${wildCardDirectory}/*` &&
wildCardDirectory !== invalidationPath | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(dynamicPath: string) => {
const [base] = dynamicPath.split('/:')
const [firstSegment] = base.split('/[')
// Ensure this is posix path as CloudFront needs forward slash in invalidation
return path.posix.join(firstSegment || '/', '*')
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(
manifest: OriginRequestDefaultHandlerManifest,
): string[] => {
return [
...Object.keys(manifest.pages.html.dynamic).map(dynamicPathToInvalidationPath),
...Object.keys(manifest.pages.html.nonDynamic),
...Object.keys(manifest.pages.ssr.dynamic).map(dynamicPathToInvalidationPath),
...Object.keys(ma... | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
async (): Promise<OriginRequestApiHandlerManifest | undefined> => {
return readJsonFile(path.join(nextBuildDir, 'api-lambda/manifest.json'))
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
async (): Promise<
OriginRequestDefaultHandlerManifest | undefined
> => {
return readJsonFile(path.join(nextBuildDir, 'default-lambda/manifest.json'))
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
async (): Promise<
OriginRequestImageHandlerManifest | undefined
> => {
return readJsonFile(path.join(nextBuildDir, 'image-lambda/manifest.json'))
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
async (): Promise<RoutesManifest | undefined> => {
return readJsonFile(path.join(nextBuildDir, 'default-lambda/routes-manifest.json'))
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
async (): Promise<PreRenderedManifest | undefined> => {
return readJsonFile(path.join(nextBuildDir, 'default-lambda/prerender-manifest.json'))
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
async (resolve, reject) => {
// The below options are needed to support following symlinks when building zip files:
// - nodir: This will prevent symlinks themselves from being copied into the zip.
// - follow: This will follow symlinks and copy the files within.
const globOptions = {
dot: true,
... | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(data) => {
shasum.update(data)
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
() => {
const hash = shasum.digest('hex')
resolve(hash)
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
async (entry: string = process.cwd()): Promise<NextBuild> => {
const buildDir = path.resolve(entry, nextBuildDir)
await fs.remove(buildDir)
const builder = new Builder(entry, nextBuildDir, {args: ['build']})
await builder.build()
const [
defaultManifest,
apiBuildManifest,
imageBuildManifest,
... | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
async (lambdaName: string): Promise<string> => {
const zipped = path.join(lambdaBuildDir, `${lambdaName}.zip`)
const hash = await zipDirectory(path.join(buildDir, lambdaName), zipped)
const output = path.join(lambdaBuildDir, `${lambdaName}.${hash}.zip`)
await fs.rename(zipped, output)
return path.... | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(pattern: string): string => {
const {basePath} = routesManifest || {}
return basePath && basePath.length > 0 ? `${basePath.slice(1)}/${pattern}` : pattern
} | nessjs/ness | src/utils/next.ts | TypeScript |
ArrowFunction |
(key) => typeof prerenderManifest.routes[key].initialRevalidateSeconds === 'number' | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type DynamicPageKeyValue = {
[key: string]: {
file: string
regex: string
}
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type OriginRequestApiHandlerManifest = {
apis: {
dynamic: DynamicPageKeyValue
nonDynamic: {
[key: string]: string
}
}
domainRedirects: {
[key: string]: string
}
enableHTTPCompression: boolean
authentication?: {
username: string
password: string
}
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type OriginRequestDefaultHandlerManifest = {
buildId: string
logLambdaExecutionTimes: boolean
pages: {
ssr: {
dynamic: DynamicPageKeyValue
nonDynamic: {
[key: string]: string
}
}
html: {
nonDynamic: {
[path: string]: string
}
dynamic: Dynamic... | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type OriginRequestImageHandlerManifest = {
enableHTTPCompression: boolean
domainRedirects: {
[key: string]: string
}
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type RedirectData = {
statusCode: number
source: string
destination: string
regex: string
internal?: boolean
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type RewriteData = {
source: string
destination: string
regex: string
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type Header = {
key: string
value: string
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type HeaderData = {
source: string
headers: Header[]
regex: string
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type I18nData = {
locales: string[]
defaultLocale: string
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type RoutesManifest = {
basePath: string
redirects: RedirectData[]
rewrites: RewriteData[]
headers: HeaderData[]
i18n?: I18nData
} | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
type CacheConfig = Record<
string,
{
cacheControl: string
path: string
prefix: string
}
> | nessjs/ness | src/utils/next.ts | TypeScript |
TypeAliasDeclaration |
export type NextBuild = {
lambdaBuildDir: string
defaultLambdaPath: string
imageLambdaPath?: string
apiLambdaPath?: string
regenerationLambdaPath?: string
assets: CacheConfig
basePath: string
staticPath: string
dataPath: string
imagePath?: string
apiPath?: string
invalidationPaths?: string[]
} | nessjs/ness | src/utils/next.ts | TypeScript |
FunctionDeclaration | /**
* Generates types to represent schema definitions in the swagger
*/
export function generateSchemaTypes(model: CodeModel, project: Project) {
// Track models that need to be imported
const importedModels = new Set<string>();
const modelsFile = project.createSourceFile(`src/models.ts`, undefined, {
overw... | ffMathy/autorest.typescript | src/restLevelClient/generateSchemaTypes.ts | TypeScript |
ArrowFunction |
(metadata) => !isNil(metadata) | lnlfps/symphony-joy | packages/server/src/metadata-scanner.ts | TypeScript |
ArrowFunction |
(prop: string) => {
const descriptor = Object.getOwnPropertyDescriptor(prototype, prop);
if (descriptor?.set || descriptor?.get) {
return false;
}
// @ts-ignore
return !isConstructor(prop) && isFunction(prototype[prop]);
} | lnlfps/symphony-joy | packages/server/src/metadata-scanner.ts | TypeScript |
ClassDeclaration |
export class MetadataScanner {
public scanFromPrototype<T extends unknown, R = any>(
instance: T,
prototype: object,
callback: (name: string) => R
): R[] {
const methodNames = new Set(this.getAllFilteredMethodNames(prototype));
return iterate(methodNames)
.map(callback)
.filter((met... | lnlfps/symphony-joy | packages/server/src/metadata-scanner.ts | TypeScript |
MethodDeclaration |
public scanFromPrototype<T extends unknown, R = any>(
instance: T,
prototype: object,
callback: (name: string) => R
): R[] {
const methodNames = new Set(this.getAllFilteredMethodNames(prototype));
return iterate(methodNames)
.map(callback)
.filter((metadata) => !isNil(metadata))
... | lnlfps/symphony-joy | packages/server/src/metadata-scanner.ts | TypeScript |
MethodDeclaration |
*getAllFilteredMethodNames(prototype: object): IterableIterator<string> {
const isMethod = (prop: string) => {
const descriptor = Object.getOwnPropertyDescriptor(prototype, prop);
if (descriptor?.set || descriptor?.get) {
return false;
}
// @ts-ignore
return !isConstructor(pro... | lnlfps/symphony-joy | packages/server/src/metadata-scanner.ts | TypeScript |
FunctionDeclaration |
export function md5(param: string): string {
let md5sum = crypto.createHash('md5');
md5sum.update(param, 'utf8');
return md5sum.digest('hex');
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function sha1(param: string): string {
let md5sum = crypto.createHash('sha1');
md5sum.update(param, 'utf8');
return md5sum.digest('hex');
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function isInteger(n: number) {
return Number(n) === n && n % 1 === 0;
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function isFloat(n: number) {
return n === Number(n) && n % 1 !== 0;
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function createArray(size: number, initValue: any): any[] {
let ret = [];
for (let i = 0; i < size; i++) {
ret.push(initValue);
}
return ret;
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function copyObject(obj: any): any {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
let result = {};
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
result[key] = copyObject(obj[key]);
}
}
return result;
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function addObject(left: any, right: any): void {
for (let key in right) {
if (right.hasOwnProperty(key)) {
if (isNaN(parseInt(right[key]))) {
continue;
}
if (!left[key]) {
left[key] = right[key];
}
else {
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function copyArray(array: Object[]): any[] {
let tempArray: any[] = [];
array.forEach((item) => {
let temp = copyObject(item);
tempArray.push(temp);
});
return tempArray;
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 在预排序数组二分查找search的下界位置
* 说明:查找第一个**大于等于**search的下标
* @param search 查找内容
* @param length 数组长度
* @param getValue 获取比较值方法
* @returns {number} 下界的下标
*/
export function lowerBound(search: number, length: number, getValue: (index: number) => number): number {
let left = 0, mid = 0, right = length, v... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 在预排序数组二分查找search的上界位置
* 说明: 查找第一个**大于**search的下标
* @param search 查找内容
* @param length 数组长度
* @param getValue 获取比较值方法
* @returns {number} 上界的下标
*/
export function upperBound(length: number, search: number, getValue: (index: number) => number): number {
let left = 0, mid = 0, right = length, va... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
*
* @param obj
* @return {boolean}
*/
export function isEmpty(obj: any): boolean {
// null and undefined are "empty"
if (obj === null) {
return true;
}
// Assume if it has a length property with a non-zero value
// that that property is correct.
if (obj.length > 0) {
ret... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* get random [0, 100]
* @return {number}
*/
export function randChance(): number {
return Math.floor(Math.random() * 101);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* get random float number (high <= low also ok)
* Math.random return number [0.0, 1.0)
* @param low
* @param high
* @return {number}
*/
export function randFloat(low: number, high: number): number {
return Math.random() * Math.abs(high - low) + Math.min(low, high);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* get random array sequence
* @param low
* @param high
* @return {number}[low, high)
*/
export function randInt(low: number, high: number): number {
return Math.floor(Math.random() * Math.abs(high - low) + Math.min(low, high));
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* get random array sequence
* @param array
* @param count - if not given, will rand the whole length of array
* @return {number[]}
*/
export function randArray(array: any[], count: number): any[] {
let i, cnt = Math.min(array.length, count || array.length), pos = 0, tmp;
for (i = 0; i < cnt - 1; i += 1... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* @param array
* @param count
* @param bRepeat
* @return {Array}
*/
export function randByWeight(array: number[], count: number, bRepeat?: boolean): number[] {
let i, sum: number = 0, result: number[] = [],
repeat: boolean = bRepeat || false,
cnt: number = Math.min(array.length, count || ar... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 根据数组中的权重返回出随机的下标
* @param array
*/
export function randOneByWeight(array: number[]): number {
return array.length === 0 ? null : randByWeight(array, 1, false)[0];
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
*
* @param obj
* @param count
* @param bRepeat
*/
export function randObjectByWeight(obj: { [key: number]: number }, count: number, bRepeat?: boolean): number[] {
let keys = Object.keys(obj), values = [];
keys.forEach((key) => {
values.push(obj[key]);
});
let rand = randByWeight(values,... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function randOneObjectByWeight(obj: { [key: number]: number }): number {
let result = randObjectByWeight(obj, 1, false);
return result.length === 0 ? null : result[0];
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 对象赚数组
* @param obj
* @return {Array}
*/
export function objectToArray(obj: any): any[] {
let arr = [];
for (let key in obj) {
arr.push(obj[key]);
}
return arr;
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 创建进程pid文件
*/
export function createPidFile(): void {
pidFile = path.join(process.cwd(), '/.pid');
fs.writeFileSync(pidFile, process.pid);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 创建游戏所使用的资源版本号文件
* @param resVersion
*/
export function createResVersionFile(resVersion): void {
curResVersion = resVersion;
let versionFile = path.join(process.cwd(), '/.res_version');
fs.writeFileSync(versionFile, curResVersion);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function getResVersion(): string {
if (curResVersion === null) {
if (fs.existsSync(path.join(process.cwd(), '/.res_version'))) {
curResVersion = fs.readFileSync(path.join(process.cwd(), '/.res_version')).toString();
}
else {
curResVersion = '';
}
}... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 字符串插入至指定idx,后续会偏移
* @param idx
* @param str
* @param strAppend
*/
export function stringInsert(idx: number, str: string, strAppend: string): string {
if (idx > str.length) {
console.error('error insert');
return '';
}
else if (idx === str.length) {
return (str + strAppend)... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 字符串反转
* @param str
*/
export function stringReverse(str: string): string {
return str.split('').reverse().join('');
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 获取指定目录下所有文件名称
* @param path
* @param reg
*/
export function fetchFileList(path: string, reg?: RegExp): string[] {
if (path[path.length - 1] !== '/') {
path = path + '/';
}
let fileList: string[] = [];
let fileNames = fs.readdirSync(path);
fileNames.forEach((fileName) => {
l... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export async function httpDownload(url, dest) {
return new Promise<void>(((resolve, reject) => {
let stream = fs.createWriteStream(dest);
request
.get(url)
.on('response', (response) => {
if (response.statusCode !== 200) {
reject(new Error... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* @example: httpGet('http://10.1.1.156/test?cmd=redis',function(error,body){},'json')
* 获取http://10.1.1.156/test?cmd=redis返回的结果并解析为json对象
*/
export async function httpGet(url: string, dataType: HTTP_RES_DATA_TYPE = HTTP_RES_DATA_TYPE.JSON, timeout?: number) {
return new Promise((resolve, reject) => {
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* http POST请求
* 比httpGet函数多了个form表单参数(Json对象),其他参数参考httpGet
* @example:
*/
export async function httpPost(url: string, form: any, dataType: HTTP_RES_DATA_TYPE = HTTP_RES_DATA_TYPE.JSON, timeout?: number) {
return new Promise((resolve, reject) => {
let options = {'url': url, 'form': form, 'timeout': ... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | //http get/post请求,返回包体解析函数
function parseHttpResBody(error: any, response: any, body: string, dataType: HTTP_RES_DATA_TYPE) {
if (error) {
//TODO:根据error.code是否为ETIMEDOUT可判断请求或响应是否超时
//如果需要可在这里增加判断是否超时的错误码
return {'error': ERROR_CODE.COMMON.HTTP_NO_RESPONSE, 'data': null};
}
if (resp... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 字符串中的字母全部大写
* @param str
*/
export function capitalize(str: string): string {
return str.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase());
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* mkdir -p
* @param dirName
*/
export function mkdirpSync(dirName) {
if (fs.existsSync(dirName)) {
return true;
}
else {
if (mkdirpSync(path.dirname(dirName))) {
fs.mkdirSync(dirName);
return true;
}
}
return false;
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration |
export function parseHttpParams(req: express.Request): { [key: string]: any } {
let urlData = url.parse(req.url);
let args = {};
// 获取get参数
if (urlData.query) {
let querySplits = urlData.query.split('&');
for (let Key in querySplits) {
if (querySplits[Key]) {
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 中文两个字符,其余一个字符
* @param {string} str
* @returns {number}
*/
export function charCodeLength(str: string): number {
let len = 0;
for (let i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
len += 2;
}
else {
len++;
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 自动机初始化,敏感词判断
*/
export function initStringChecker() {
stringChecker = new StringChecker();
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 自动机构建,构建敏感词库
* @param filterStrings
*/
export function buildFilterString(filterStrings: string[]) {
for (let s of filterStrings) {
stringChecker.addPattern(s);
}
stringChecker.build();
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 如果含有敏感词,会将字符串中的敏感词替换成 ***
* @param msg
*/
export function filterString(msg) {
return stringChecker.replace(msg);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 删除目录下所有内容
* @param path
*/
export function rmAll(path) {
let files = [];
if (fs.existsSync(path)) {
files = fs.readdirSync(path);
for (let file of files) {
let curPath = path + '/' + file;
if (fs.statSync(curPath).isDirectory()) {
rmAll(curPath);
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
FunctionDeclaration | /**
* 注册进程通用事件
* @param shutDownCallBack
*/
export function registerProcessListener(shutDownCallBack?: Function) {
process.on('uncaughtException', (error => {
console.error(error);
Log.sError(error);
// process.exit(1);
}));
process.on('unhandledRejection', (reason, p) => {
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(item) => {
let temp = copyObject(item);
tempArray.push(temp);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(key) => {
values.push(obj[key]);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(pos) => {
result.push(parseInt(keys[pos]));
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(fileName) => {
let fullPath = path + fileName;
let stat = fs.statSync(fullPath);
if (!stat.isDirectory()) {
if (reg) {
if (reg.test(fileName)) {
fileList.push(fileName);
}
}
else {
fileList.... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
let stream = fs.createWriteStream(dest);
request
.get(url)
.on('response', (response) => {
if (response.statusCode !== 200) {
reject(new Error(url + ' failed'));
}
else {
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(response) => {
if (response.statusCode !== 200) {
reject(new Error(url + ' failed'));
}
else {
response
.pipe(stream)
.on('close', () => {
resolve();
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
() => {
resolve();
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(e) => {
reject(new Error(url + e));
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(e) => {
reject(new Error(url + e));
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
let options = {'url': url, 'form': null, 'timeout': timeout};
request.get(options, (error, response, body) => {
let result = parseHttpResBody(error, response, body, dataType);
if (error) {
reject(result.error);
}
els... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(error, response, body) => {
let result = parseHttpResBody(error, response, body, dataType);
if (error) {
reject(result.error);
}
else {
resolve(result.data);
}
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
let options = {'url': url, 'form': form, 'timeout': timeout};
request.post(options, (error, response, body) => {
let result = parseHttpResBody(error, response, body, dataType);
if (result.error) {
reject(result.error);
}
... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(error, response, body) => {
let result = parseHttpResBody(error, response, body, dataType);
if (result.error) {
reject(result.error);
}
else {
resolve(result.data);
}
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(L) => L.toUpperCase() | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
error => {
console.error(error);
Log.sError(error);
// process.exit(1);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(reason, p) => {
console.error('Unhandled Rejection at:', p, 'reason:', reason);
Log.sError('Unhandled Rejection at:', p, 'reason:', reason);
// process.exit(1);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
async () => {
if (shutDownCallBack) {
Global.isAppValid = false;
await shutDownCallBack();
}
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
() => {
this._isRunning = true;
this.promise.apply(this.promiseScope)
.then(() => {
this._isRunning = false;
this.run();
})
.catch((e) => {
Log.sError(e);
if (!this.bO... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
() => {
this._isRunning = false;
this.run();
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(e) => {
Log.sError(e);
if (!this.bOnExceptionQuit) {
this._isRunning = false;
this.run();
}
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
(resolve) => {
if (this._isRunning) {
setTimeout(() => {
this.stop().then(resolve);
}, 100);
}
else {
resolve();
}
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ArrowFunction |
() => {
this.stop().then(resolve);
} | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
ClassDeclaration | /**
* 在终止条件之前会一直按照一定的时间间隔 达到loop的效果,保证每两次promise的时间间隔一定是interval时间
*/
export class Loop {
interval: number;
promise: () => Promise<void>;
terminateCallBack: () => boolean;
promiseScope: any;
bOnExceptionQuit: boolean;
private _isRunning: boolean;
private _isForceQuit: boolean;
constru... | sunwenteng/bgserver | src/lib/util/game_util.ts | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.