当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Debug.default函数代码示例

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


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

示例1: debug

 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import debug from 'debug';
import {fromBytes4} from './byte';
import HeartBeat from './heartbeat';
import {IObservable, TDecodeBuffSubscriber} from './types';
import {noop} from './util';

const MAGIC_HIGH = 0xda;
const MAGIC_LOW = 0xbb;
const HEADER_LENGTH = 16;
const log = debug('dubbo:decode-buffer');

/**
 * 在并发的tcp数据传输中,会出现少包,粘包的现象
 * 好在tcp的传输是可以保证顺序的
 * 我们需要抽取一个buff来统一处理这些数据
 */
export default class DecodeBuffer
  implements IObservable<TDecodeBuffSubscriber> {
  /**
   * 初始化一个DecodeBuffer
   * @param pid socket-worker的pid
   */
  private constructor(pid: number) {
    log('new DecodeBuffer');
    this._pid = pid;
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:31,代码来源:decode-buffer.ts

示例2: debug

import { ServerApp } from '@feathersjs/feathers';
import service from 'feathers-mongoose';
import debug from 'debug';
import UserSettings from '@typings/UserSettings';

import Model from './Model';
import hooks from './hooks';
import events from './events';

const log = debug('TF2Pickup:user-settings');

export default function userSettings(app: ServerApp) {
  log('Setting up user-settings service');

  app.use('/user-settings', service({
    Model,
    id: 'id',
  }));

  app.configure(events);

  app
    .service('user-settings')
    .hooks(hooks)
    // Publish the events only to the userId that owns the document
    .publish(
      'patched',
      (data: UserSettings) => app
        .channel('authenticated')
        .filter(connection => connection.user.id === data.id),
    );
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:31,代码来源:index.ts

示例3: debug

import debug from 'debug';
import { yarnOrNpmSpawn, hasYarn } from './yarn-or-npm';

const d = debug('electron-forge:dependency-installer');

export default async (
  dir: string,
  deps: string[],
  areDev = false,
  exact = false,
) => {
  d('installing', JSON.stringify(deps), 'in:', dir, `dev=${areDev},exact=${exact},withYarn=${hasYarn()}`);
  if (deps.length === 0) {
    d('nothing to install, stopping immediately');
    return Promise.resolve();
  }
  let cmd = ['install'].concat(deps);
  if (hasYarn()) {
    cmd = ['add'].concat(deps);
    if (areDev) cmd.push('--dev');
    if (exact) cmd.push('--exact');
  } else {
    if (exact) cmd.push('--save-exact');
    if (areDev) cmd.push('--save-dev');
    if (!areDev) cmd.push('--save');
  }
  d('executing', JSON.stringify(cmd), 'in:', dir);
  try {
    await yarnOrNpmSpawn(cmd, {
      cwd: dir,
      stdio: 'pipe',
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:31,代码来源:install-dependencies.ts

示例4: debug

import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import logSymbols from 'log-symbols';

const d = debug('electron-forge:init:directory');

export default async (dir: string) => {
  await asyncOra('Initializing Project Directory', async (initSpinner) => {
    d('creating directory:', dir);
    await fs.mkdirs(dir);

    const files = await fs.readdir(dir);
    if (files.length !== 0) {
      d('found', files.length, 'files in the directory.  warning the user');
      initSpinner.stop(logSymbols.warning);
      throw `The specified path: "${dir}" is not empty, do you wish to continue?`;
    }
  });
};
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:20,代码来源:init-directory.ts

示例5:

import axios from 'axios'
import crypto from 'crypto'
import _debug from 'debug'
import googleTranslateAPI from 'google-translate-api'
import { Middleware } from 'koa'
import qs from 'qs'

import { Locale } from 'types'
import { LOCALE_COOKIE, TOGGLE_LOCALE } from 'utils'

const debug = _debug('1stg:transalte')

const SIGNATURE_PREFIX = 'GETtmt.tencentcloudapi.com/?'

interface TranslateParams {
  Source: Locale
  SourceText: string
}

const getTranslatePrams = (params: TranslateParams) => ({
  Action: 'TextTranslate',
  Region: 'ap-shanghai',
  SecretId: process.env.TENCENT_TRANSLATE_API_SECRET_ID,
  SignatureMethod: 'HmacSHA256',
  Timestamp: Math.ceil(Date.now() / 1000),
  Nonce: Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER),
  Version: '2018-03-21',
  ProjectId: 0,
  ...params,
  Target: TOGGLE_LOCALE[params.Source],
})
开发者ID:JounQin,项目名称:blog,代码行数:31,代码来源:translate.ts

示例6: createMessageHandler

import http from 'http';
import debug from 'debug';
import ioServer from 'socket.io';
import {
  BuildMessage,
  SERVER_MESSAGE_EVENT_NAME
} from 'react-cosmos-shared2/build';
import { RENDERER_MESSAGE_EVENT_NAME } from 'react-cosmos-shared2/renderer';

const d = debug('cosmos:message');

export function createMessageHandler(httpServer: http.Server) {
  d('init');
  const io = ioServer(httpServer);

  io.on('connection', socket => {
    d('connection');
    // Forward commands between connected clients. Parties involved can be the
    // - The Cosmos UI, which acts as a remote control
    // - The web iframe or the React Native component renderers
    socket.on(RENDERER_MESSAGE_EVENT_NAME, msg => {
      d('on renderer message %o', msg);
      socket.broadcast.emit(RENDERER_MESSAGE_EVENT_NAME, msg);
    });
  });

  function sendMessage(msg: BuildMessage) {
    d('send server message %o', msg);
    io.emit(SERVER_MESSAGE_EVENT_NAME, msg);
  }
开发者ID:skidding,项目名称:cosmos,代码行数:30,代码来源:messageHandler.ts

示例7: toImport

 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import debug from 'debug';
import {relative,sep} from 'path';
import {ImportDeclarationStructure} from 'ts-simple-ast';

const log = debug('j2t:core:toImport');

export interface IToImportParam {
  className: string;
  classPath: string;
  packagePath: string;
}

/**
 * java import 转换为ts的import ast
 * @param {any} className
 * @param {any} classPath
 * @param {any} packagePath
 * @returns {ImportDeclarationStructure}
 */
export function toImport({
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:31,代码来源:to-import.ts

示例8: debug

 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import debug from 'debug';
import {IJFieldPropers, ITypePropers, ITypeSearch} from '../typings';

const log = debug('j2t:core:ast-parse-util');

/**
 * java 类型映射到TS中的值;;
 * @type {{String: string; Integer: string; Integer: string}}
 *
 * eg:
 *
 *
 */
const javaType2JSMap = {
  'java.lang.String': 'string',
  'java.lang.Object': 'Object',
  'java.lang.Integer': 'number',
  'java.lang.int': 'number',
  'java.lang.short': 'number',
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:31,代码来源:type-parse.ts

示例9: hash

import net = require('net');
import cluster = require('cluster');
import _ = require('lodash');
var debug = require('debug');

var masterDebug = debug('ChatUp:ChatWorker:master');
var slaveDebug = debug('ChatUp:ChatWorker:slave');
// Copied from the great module of indutny : sticky-session
// https://github.com/indutny/sticky-session
// Modified to implement a truly random routing, for benchmark purpose

function hash(ip, seed) {
  var hash = ip.reduce(function(r, num) {
    r += parseInt(num, 10);
    r %= 2147483648;
    r += (r << 10)
    r %= 2147483648;
    r ^= r >> 6;
    return r;
  }, seed);

  hash += hash << 3;
  hash %= 2147483648;
  hash ^= hash >> 11;
  hash += hash << 15;
  hash %= 2147483648;

  return hash >>> 0;
}

interface StickyOptions {
开发者ID:geekuillaume,项目名称:ChatUp,代码行数:31,代码来源:sticky.ts

示例10: disallow

import {disallow} from 'feathers-hooks-common';
import auth from '@feathersjs/authentication';
import {
  BeforeHookContext,
  DefaultDocument,
  Hooks,
} from '@feathersjs/feathers';
import debug from 'debug';

const log = debug('TF2Pickup:hooks');

const disallowExternal = (hook: BeforeHookContext<DefaultDocument>) => {
  if (hook.path === 'authentication') {
    return hook;
  }

  return disallow('external')(hook);
};

function requireAuth(
  hook: BeforeHookContext<DefaultDocument>
) {
  if (hook.params.provider === 'external') {
    return auth.hooks.authenticate(['jwt'])(hook);
  }

  return hook;
}

const hooks: Hooks<DefaultDocument> = {
  before: {
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:31,代码来源:hooks.ts


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