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


TypeScript util.inherits函数代码示例

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


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

示例1: create

export function create(options: ErrorOptions) {
	function Err(message: string) {
		this.message = message;
	}
	util.inherits(Err, Error);
	Err.prototype.name = options.name;
	return Err;
}
开发者ID:smikes,项目名称:eclint,代码行数:8,代码来源:errorFactory.ts

示例2: it

    it('inherits when used with require(util).inherits', function () {
        class Beast extends EventEmitter {
            /* rawr, i'm a beast */
        }

        util.inherits(Beast, EventEmitter);

        var moop = new Beast()
            , meap = new Beast();

        assert.strictEqual(moop instanceof Beast, true);
        assert.strictEqual(moop instanceof EventEmitter, true);

        moop.listeners('click');
        meap.listeners('click');

        moop.addListener('data', function () {
            throw new Error('I should not emit');
        });

        meap.emit('data', 'rawr');
        meap.removeAllListeners();
    });
开发者ID:rchaser53,项目名称:DefinitelyTyped,代码行数:23,代码来源:fbemitter-tests.ts

示例3: require

var connection = require('../../connection'),
    util = require('util'),
    Promise = require('bluebird'),
    EventEmitter = require('events').EventEmitter,
    _ = require('lodash');
helper = require('../helper');
var nestSetModel = function () {
};
util.inherits(nestSetModel, EventEmitter);
nestSetModel.prototype.insertNode = function (data, parent) {
    return this.insertRight(data, parent);
};
nestSetModel.prototype.insertRight = function (data, parent) {
    var self = this;
    var updateLeftSql = 'UPDATE `apt_categories` SET `left` = `left` + 2 WHERE `left` > ' + parent.right;
    var updateRightSql = 'UPDATE `apt_categories` SET `right` = `right` + 2 WHERE `right` >= ' + parent.right;
    return new Promise(function (resolveAll, rejectAll) {
        var insertRightPromise = new Promise(function (resolve, reject) {
            connection.query(updateLeftSql, function (err) {
                if (err) reject(err);
                resolve();
            });
        });
        insertRightPromise.then(function () {
            return new Promise(function (resolve, reject) {
                connection.query(updateRightSql, function (err) {
                    if (err) reject(err);
                    resolve();
                });
            });
        }).then(function () {
开发者ID:ttlpta,项目名称:nodejs-ecomerce,代码行数:31,代码来源:nestedSetModel.ts

示例4: catch

    logger.info('External access:', PeerDTO.fromJSONObject(p2).getURL())
    logger.debug('Generating server\'s peering entry based on block#%s...', p2.block.split('-')[0]);
    p2.signature = await this.server.sign(raw2);
    p2.pubkey = this.selfPubkey;
    // Remember this is now local peer value
    this.peerInstance = p2;
    try {
      // Submit & share with the network
      await this.server.writePeer(p2)
    } catch (e) {
      logger.error(e)
    }
    const selfPeer = await this.dal.getPeer(this.selfPubkey);
    // Set peer's statut to UP
    await this.peer(selfPeer);
    this.server.streamPush(selfPeer);
    logger.info("Next peering signal in %s min", signalTimeInterval / 1000 / 60);
    return selfPeer;
  }

  private getOtherEndpoints(endpoints:string[], theConf:ConfDTO) {
    return endpoints.filter((ep) => {
      return !ep.match(constants.BMA_REGEXP) || (
          !(ep.includes(' ' + theConf.remoteport) && (
          ep.includes(theConf.remotehost || '') || ep.includes(theConf.remoteipv6 || '') || ep.includes(theConf.remoteipv4 || ''))));
    });
  }
}

util.inherits(PeeringService, events.EventEmitter);
开发者ID:Kalmac,项目名称:duniter,代码行数:30,代码来源:PeeringService.ts

示例5: function

    this.path = path;
    var self = this;

    this.writeToComputer = function(data) {
        self.emit("data", data);
    };

    if (options.autoOpen) {
        process.nextTick(function() {
            self.open(callback);
        });
    }
     
};

util.inherits(VirtualSerialPort, events.EventEmitter);

VirtualSerialPort.prototype.open = function open(callback) {
    console.log("Called Open ", this.path);
    
    if (this.path.indexOf("not") > -1) {
        this.open = false;
        this.emit('error');
    } else {
        this.open = true;
        this.emit('open');
    }
   
    if(callback) {
        callback();
    }
开发者ID:nodesense,项目名称:nodesense-modbus-serial,代码行数:31,代码来源:virtual-serialport.ts

示例6: start

  start() {
    var self = this;

    self.operations = []

    function schedule_operation(op) {
        self.operations.push(op);
    }

    function DiaCommandLine() {
        cmdln.Cmdln.call(this, {
            name: "dt",
            desc: "Devops ergonomics for Kubernetes.",
            options: [
                {
                    names: ['help', 'h'],
                    help: 'Show this help message and exit.',
                    type: 'bool'
                },
                {
                    names: ["directory", "d"],
                    type: 'string',
                    helpArg: "DIR",
                    help: "Specify your project directory (ie, contains the Diafile)"
                }
            ]
        });
    };
    util.inherits(DiaCommandLine, cmdln.Cmdln);

    DiaCommandLine.prototype.init = function(opts, args, callback) {
        if(opts["directory"] !== undefined) {
            // user specified directory!
            self.project_directory = opts["directory"];
            
        }
        return cmdln.Cmdln.prototype.init.call(this, opts, args, callback);
    }

    function GenerateCommand() {
        cmdln.Cmdln.call(this, {
            name: "dt generate",
            desc: "Generate new resources."
        });
    };
    util.inherits(GenerateCommand, cmdln.Cmdln);

    // TODO: generate all of the generate subcommands programmatically
    // from our generators, and then have the callbacks create
    // Operations.
    GenerateCommand.prototype.do_pod = function(subcmd, opts, args, callback) {
        callback();
    };

    DiaCommandLine.prototype.do_generate = function(subcmd, opts, args, callback) {
        // HACK: in order to fool Cmdln into nesting itself, add two dummy
        // entries to the array.
        cmdln.main(GenerateCommand, ["_", "_"].concat(args));
        callback();
    };
    DiaCommandLine.prototype.do_generate.help = "Generate new resources.";

    DiaCommandLine.prototype.do_deploy = function(subcmd, opts, args, callback) {
        var deploy = require("./commands/deploy");
        schedule_operation(new deploy.Deploy());
        logger.debug("yay");
        callback();
    };
    DiaCommandLine.prototype.do_deploy.help = "Ensure all resources in the Kubernetes cluster are up to date.";

    DiaCommandLine.prototype.do_status = function(subcmd, opts, args, callback) {
        var status = require("./commands/status");
        schedule_operation(new status.Status());
        callback();
    };
    DiaCommandLine.prototype.do_status.help = "Check the state of the cluster.";

    DiaCommandLine.prototype.do_build = function(subcmd, opts, args, callback) {
        var build = require("./commands/build");
        schedule_operation(new build.Build());
        callback();
    };
    DiaCommandLine.prototype.do_build.help = "Check the state of the cluster.";

    logger.debug("Parsing command line...");
    var cli = new DiaCommandLine();
    // we never emit an unhandled exception unless something is broken.
    cli.showErrStack = true;
    
    // HACK: break cmdln's behaviour of using process.exit:
    // waiting on https://github.com/trentm/node-cmdln/issues/11
    var actualExit = process.exit;
    process.exit = function() { };
    cmdln.main(cli);
    process.exit = actualExit;

    // now, set the defaults for the options:
    this.project_directory =  this.project_directory || process.cwd();

    var kube;
//.........这里部分代码省略.........
开发者ID:orospakr,项目名称:diatropikon,代码行数:101,代码来源:diatropikon.ts

示例7: new

/**
 * Forwards logs through the LSP connection once it is set up.
 *
 * This is written somewhat strangely as winston seems to require that it be an
 * ES5-style class with inheritance through util.inherits.
 */
interface ForwardingTransport extends Transport {}
interface ForwardingTransportStatic {
  new(options: any): ForwardingTransport;

  console: RemoteConsole|undefined;
}
const ForwardingTransport = function(
                                this: ForwardingTransport, _options: any) {} as
    any as ForwardingTransportStatic;
util.inherits(ForwardingTransport, Transport);
ForwardingTransport.console = undefined;

ForwardingTransport.prototype.log = function(
    this: ForwardingTransport,
    level: plylog.Level,
    msg: string,
    _meta: any,
    callback: (err: Error|null, success: boolean) => void) {
  if (typeof msg !== 'string') {
    msg = util.inspect(msg);
  }
  const console = ForwardingTransport.console;
  if (!console) {
    // TODO(rictic): store these calls in memory and send them over when the
    //     console link is established.
开发者ID:Polymer,项目名称:tools,代码行数:31,代码来源:intercept-logs.ts

示例8: require

 * @author Maciej Sopyło (killah)
 * Copyright 2012 Maciej Sopyło @ KILLAHFORGE.
 *
 * MIT License
 */

var spawn = require('child_process').spawn,
    events = require('events'),
    util = require('util');

module.exports = function Sound(filename) {
    events.EventEmitter.call(this);
    this.filename = filename;
};

util.inherits(module.exports, events.EventEmitter);

module.exports.prototype.play = function () {
    this.stopped = false;
    this.process = spawn('mpg123', [this.filename]);
    var self = this;
    this.process.on('exit', function (code, sig) {
        if (code !== null && sig === null) {
            self.emit('complete');
        }
    });
};
module.exports.prototype.stop = function () {
    this.stopped = true;
    this.process.kill('SIGTERM');
    this.emit('stop');
开发者ID:coolkev,项目名称:pumpkinlights,代码行数:31,代码来源:mpg123.ts

示例9: Promise

};
interface ProductModel {
    id: number;
    name: string;
    category_id: number;
    image_path: string;
    price: string;
    model: string;
    quantity: string;
    promotion_id: string;
    brand_id: string;
    status: string;
    date_added: string;
    date_modified: string;
};
util.inherits(Product, EventEmitter);
Product.prototype.listProduct = function () {
    var sql = "SELECT `apt_product`.*, `apt_brand`.`name` as 'brand_name', `apt_categories`.`name` as 'category_name'" +
        " FROM `apt_product`, `apt_brand`, `apt_categories`" +
        " WHERE `apt_product`.brand_id = `apt_brand`.id AND `apt_product`.category_id = `apt_categories`.id";
    return new Promise(function (resolve, reject) {
        connection.query(sql, (err, rows) => {
            if (err) reject(err);
            var products = [];
            for (var product of rows) {
                product.date_added = new Date(+product.date_added);
                products.push(product);
            }
            resolve(products);
        });
    });
开发者ID:ttlpta,项目名称:nodejs-ecomerce,代码行数:31,代码来源:productModel.ts

示例10: arrify

  };

  if (options.scopes) {
    config.scopes = config.scopes.concat(options.scopes);
  }

  common.Service.call(this, config, options);

  /**
   * @name BigQuery#location
   * @type {string}
   */
  this.location = options.location;
}

util.inherits(BigQuery, common.Service);

/**
 * Merge a rowset returned from the API with a table schema.
 *
 * @private
 *
 * @param {object} schema
 * @param {array} rows
 * @returns {array} Fields using their matching names from the table's schema.
 */
(BigQuery as any).mergeSchemaWithRows_ = BigQuery.prototype.mergeSchemaWithRows_ = function(
  schema,
  rows
) {
  return arrify(rows)
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:31,代码来源:index.ts

示例11: require

var connection = require('../../connection'),
    util = require('util'),
    _ = require('lodash'),
    EventEmitter = require('events').EventEmitter,
    helper = require('../helper');
var Brand = function () {

};
interface BrandModel {
    id: number;
    name: string;
    logo_image: string;
};
util.inherits(Brand, EventEmitter);
Brand.prototype.listBrand = function () {
    var sql: string = helper.buildQuery
        .select('*')
        .from('apt_brand')
        .render();
    return new Promise(function (resolve, reject) {
        connection.query(sql, (err, rows) => {
            if (err) reject(err);
            resolve(rows);
        });
    });
};
Brand.prototype.getBrandById = function (params) {
    var sql: string = helper.buildQuery
        .select('*')
        .from('apt_brand')
        .where({ id: params.id })
开发者ID:ttlpta,项目名称:nodejs-ecomerce,代码行数:31,代码来源:brandModel.ts

示例12: new

/**
 * Forwards logs through the LSP connection once it is set up.
 *
 * This is written somewhat strangely as winston seems to require that it be an
 * ES5-style class with inheritance through util.inherits.
 */
interface ForwardingTransport extends winston.TransportInstance {}
interface ForwardingTransportStatic {
  new (options: any): ForwardingTransport;

  console: RemoteConsole|undefined;
}
const ForwardingTransport = function(this: ForwardingTransport, _options: any) {
} as any as ForwardingTransportStatic;
util.inherits(ForwardingTransport, winston.Transport);
ForwardingTransport.console = undefined;

ForwardingTransport.prototype.log = function(
    this: ForwardingTransport, level: plylog.Level, msg: string, _meta: any,
    callback: (err: Error|null, success: boolean) => void) {
  if (typeof msg !== 'string') {
    msg = util.inspect(msg);
  }
  const console = ForwardingTransport.console;
  if (!console) {
    // TODO(rictic): store these calls in memory and send them over when the
    //     console link is established.
    return;
  }
  switch (level) {
开发者ID:MehdiRaash,项目名称:tools,代码行数:30,代码来源:intercept-logs.ts

示例13: require

var connection = require('../../connection'),
    util = require('util'),
    _ = require('lodash'),
    EventEmitter = require('events').EventEmitter;
var UserGroupCombinePermission = function () {
};
util.inherits(UserGroupCombinePermission, EventEmitter);
UserGroupCombinePermission.prototype.addAllowGroupPermission = function (groupId, allowPermissionIds) {
    return new Promise(function (resolve, reject) {
        if (!_.isEmpty(allowPermissionIds)) {
            var insertValues: string = '(' + allowPermissionIds.join(',' + groupId + '),(') + ',' + groupId + ')';
            var sql: string = 'INSERT IGNORE INTO `apt_permission_combine_group` (`permission_id`, `user_group_id`) ' +
                'VALUES ' + insertValues;
            connection.query(sql, function (err, res) {
                if (err) {
                    reject(err);
                } else {
                    resolve();
                }
            });
        } else {
            resolve();
        }
    });
};
UserGroupCombinePermission.prototype.removeDenyGroupPermission = function (groupId, denyPermissionIds) {
    return new Promise(function (resolve, reject) {
        if (!_.isEmpty(denyPermissionIds)) {
            var deleteValues: string = denyPermissionIds.join(',');
            var sql: string = 'DELETE FROM `apt_permission_combine_group` WHERE `user_group_id` = ? ' +
                'AND `permission_id` IN ( ' + deleteValues + ' )';
开发者ID:ttlpta,项目名称:nodejs-ecomerce,代码行数:31,代码来源:usergroupCombinePermissionModel.ts

示例14: function

      this.postMessageToUser(userName, `${getRandomElement(SUCCESS_PREFIXES)} ${text}`)
    })
  }
}

const userById = function(id: string): (user: any) => boolean {
  return function(user: any): boolean{
    return user.id === id;
  }
}

const getRandomElement = function(array: any[]): any {
  return array[Math.floor(Math.random()*array.length)];
}

const getTrigger = function(triggers: string[], message: string): string {
  return triggers.find( 
    (triggerType: string, triggerList: string[]): boolean => isInTriggerList(message, triggerList) 
  ) || ''
}

const isInTriggerList = function(message: string, triggerList: string[]): boolean {
  return triggerList.find(
    (trigger: string): boolean => message.indexOf(trigger) > -1
  ) !== undefined
}

NickisBot.prototype = Prototype;
util.inherits(NickisBot, slackbots);
module.exports = NickisBot;
开发者ID:bananaCypher,项目名称:nickis_bot,代码行数:30,代码来源:nickis_bot.ts

示例15: require

require('source-map-support').install();

const util = require('util');
const stream = require('stream');
const fs = require('fs');
const iconv = require('iconv-lite');
const _ = require('underscore');

function StringifyStream() {
	stream.Transform.call(this);

	this._readableState.objectMode = false;
	this._writableState.objectMode = true;
}
util.inherits(StringifyStream, stream.Transform);

StringifyStream.prototype._transform = function(obj, encoding, cb){
	this.push(JSON.stringify(obj));
	cb();
};

export declare class Record {

	account: string;
	category: string;
	currency: string;
	amount: string;
	payment_type: string;
	date: string;
	note: string;
开发者ID:spidgorny,项目名称:umsaetze,代码行数:30,代码来源:runSpardaBank.ts


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