當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore.values函數代碼示例

本文整理匯總了TypeScript中underscore.values函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript values函數的具體用法?TypeScript values怎麽用?TypeScript values使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了values函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: attempt

  public attempt(context: ReplyContext) {
    const normalizedText = context.sourceMessage.text.toLowerCase()
    const shortCommands = _.sortBy(_.values(Looker.customCommands), (c) => -c.name.length)
    const matchedCommand = shortCommands.filter((c) => normalizedText.indexOf(c.name) === 0)[0]
    if (matchedCommand) {

      const { dashboard } = matchedCommand
      const query = context.sourceMessage.text.slice(matchedCommand.name.length).trim()
      normalizedText.indexOf(matchedCommand.name)

      context.looker = matchedCommand.looker

      const filters: {[key: string]: string} = {}
      const dashboardFilters = dashboard.dashboard_filters || dashboard.filters
      for (const filter of dashboardFilters) {
        filters[filter.name] = query
      }
      const runner = new DashboardQueryRunner(context, matchedCommand.dashboard, filters)
      runner.start()

      return true
    } else {
      return false
    }
  }
開發者ID:DipJar,項目名稱:looker-slackbot,代碼行數:25,代碼來源:custom_command.ts

示例2: constructor

    constructor(opts: DaoOptions<T>) {
        this.tablename = opts.tablename;
        this.columnsMapping = opts.columnsMapping;
        this.objectconstructor = opts.objectconstructor;
        this.columnsMappingLength = _.keys(this.columnsMapping).length;
        this.columnsMappingKeys = _.keys(this.columnsMapping);
        this.columnsMappingValues = _.values(this.columnsMapping);
        this.primarykey = opts.primarykey;

        // Generate insert query string
        this.insertQuery = "INSERT INTO " + this.tablename + " (";
        let includeLength = 0;
        let args: any[] = [];
        let i = 0;
        while (i < this.columnsMappingLength - 1) {
            this.insertQuery += this.columnsMappingValues[i] + ", ";
            i++;
        }

        this.insertQuery += this.columnsMappingValues[i];
        this.insertQuery += ") values(";
        i = 0;
        while (i < this.columnsMappingLength - 1) {
            this.insertQuery += "?, ";
            i++;
        }
        this.insertQuery += "?);";
    }
開發者ID:JohanBaskovec,項目名稱:libraryBackEnd,代碼行數:28,代碼來源:GoodORM.ts

示例3: reduceBy

function reduceBy(reducables: any[], properties: string[]) {
  const reduced = reducables.reduce((map, entry) => {
    const id = properties.map((prop) => entry[prop]).join('-');
    map[id] = map[id] || [];
    map[id].push(entry);
    return map;
  }, {});
  return _.values(reduced).map((rows: any[]) => reduce(rows))
}
開發者ID:Kalmac,項目名稱:duniter,代碼行數:9,代碼來源:IndexedBlockchain.ts

示例4: constructor

 constructor(opts: DaoOptions<T>) {
     this.tablename = opts.tablename;
     this.columnsMapping = opts.columnsMapping;
     this.objectconstructor = opts.objectconstructor;
     this.columnsMappingLength = _.keys(this.columnsMapping).length;
     this.columnsMappingKeys = _.keys(this.columnsMapping);
     this.columnsMappingValues = _.values(this.columnsMapping);
     this.primarykey = opts.primarykey;
 }
開發者ID:JohanBaskovec,項目名稱:nodejslibrary,代碼行數:9,代碼來源:GoodORM.ts

示例5: async

 onConfiguredExecute: async (server:any, conf:ConfDTO, program:any, params:any, wizardTasks:any) => {
   const step = params[0];
   const tasks = step ? [wizardTasks[step]] : _.values(wizardTasks);
   for (const task of tasks) {
     if (!task) {
       throw 'Unknown task';
     }
     await task(conf, program)
   }
   // Check config
   await server.checkConfig();
   await server.dal.saveConf(conf);
   logger.debug("Configuration saved.");
 }
開發者ID:Kalmac,項目名稱:duniter,代碼行數:14,代碼來源:wizard.ts

示例6: constructor

    constructor(options:ParseTemplate) {
		this._keys = _.keys(options.template.props);
		this._mappings = _.values(options.template.props);
		this._name = options.name;
		this._props = options.template.props;

		// set document context
		if (options.template.context) {

			if (_.isString(options.template.context)) {
				this._documentSelector = options.template.context;
			} else {
				this._documentSelector = options.template.context.selector;
				this._documentSelectorIndex = options.template.context.index;
			}
		} else {
			throw new Error('Missing template context');
		}
	}
開發者ID:molekilla,項目名稱:menio,代碼行數:19,代碼來源:menio.ts

示例7: dump

function dump(mode: "E" | "D", args1: [any?, ...any[]]) {

    const a2 = _.values(args1) as [string, ...string[]];
    const output = format.apply(null, a2);
    let a1 = [buildPrefix(mode)];

    let i = 0;
    for (const line of output.split("\n")) {
        const lineArguments = ([] as string[]).concat(a1, [line]) as [string, ...string[]];
        console.log.apply(console, lineArguments);
        a1 = [continuation];
        i = i + 1;
        if (i > maxLines) {
            const a3 = a1.concat([" .... TRUNCATED ....."]);
            console.log.apply(console, a3 as [string, ...string[]]);
            break;
        }
    }

}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:20,代碼來源:make_loggers.ts

示例8: constructNamespaceDependency

function constructNamespaceDependency(
  namespace: NamespacePrivate
) {

    const addressSpace = namespace.addressSpace;

    // navigate all namespace recursively to
    // find dependency
    const dependency = [];
    const depMap = new Set();

    // default namespace is always first
    dependency.push(addressSpace.getDefaultNamespace());
    depMap.add(dependency[0].index);

    if (namespace !== addressSpace.getDefaultNamespace()) {
        dependency.push(namespace);
        depMap.add(namespace.index);
    }

    for (const node of _.values(namespace._nodeid_index)) {
        // visit all reference
        const references = node.ownReferences();
        for (const reference of references) {
            // check referenceId
            const namespaceIndex = reference._referenceType!.nodeId.namespace;
            if (!depMap.has(namespaceIndex)) {
                depMap.add(namespaceIndex);
                dependency.push(addressSpace.getNamespace(namespaceIndex));
            }
            const namespaceIndex2 = reference.nodeId.namespace;
            if (!depMap.has(namespaceIndex2)) {
                depMap.add(namespaceIndex2);
                dependency.push(addressSpace.getNamespace(namespaceIndex2));
            }
        }
    }
    return dependency;
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:39,代碼來源:nodeset_to_xml.ts

示例9: lookup

 async lookup(req:any): Promise<HttpLookup> {
   // Get the search parameter from HTTP query
   const search = await ParametersService.getSearchP(req);
   // Make the research
   const identities:any[] = await this.IdentityService.searchIdentities(search);
   // Entitify each result
   identities.forEach((idty, index) => identities[index] = DBIdentity.copyFromExisting(idty));
   // Prepare some data to avoid displaying expired certifications
   for (const idty of identities) {
     const certs = await this.server.dal.certsToTarget(idty.pubkey, idty.getTargetHash());
     const validCerts = [];
     for (const cert of certs) {
       const member = await this.IdentityService.getWrittenByPubkey(cert.from);
       if (member) {
         cert.uids = [member.uid];
         cert.isMember = member.member;
         cert.wasMember = member.wasMember;
       } else {
         const potentials = await this.IdentityService.getPendingFromPubkey(cert.from);
         cert.uids = _(potentials).pluck('uid');
         cert.isMember = false;
         cert.wasMember = false;
       }
       validCerts.push(cert);
     }
     idty.certs = validCerts;
     const signed = await this.server.dal.certsFrom(idty.pubkey);
     const validSigned = [];
     for (let j = 0; j < signed.length; j++) {
       const cert = _.clone(signed[j]);
       cert.idty = await this.server.dal.getIdentityByHashOrNull(cert.target);
       if (cert.idty) {
         validSigned.push(cert);
       } else {
         this.logger.debug('A certification to an unknown identity was found (%s => %s)', cert.from, cert.to);
       }
     }
     idty.signed = validSigned;
   }
   if (identities.length == 0) {
     throw BMAConstants.ERRORS.NO_MATCHING_IDENTITY;
   }
   const resultsByPubkey:any = {};
   identities.forEach((identity) => {
     const copy = DBIdentity.copyFromExisting(identity)
     const jsoned = copy.json();
     if (!resultsByPubkey[jsoned.pubkey]) {
       // Create the first matching identity with this pubkey in the map
       resultsByPubkey[jsoned.pubkey] = jsoned;
     } else {
       // Merge the identity with the existing(s)
       const existing = resultsByPubkey[jsoned.pubkey];
       // We add the UID of the identity to the list of already added UIDs
       existing.uids = existing.uids.concat(jsoned.uids);
       // We do not merge the `signed`: every identity with the same pubkey has the same `signed` because it the *pubkey* which signs, not the identity
     }
   });
   return {
     partial: false,
     results: _.values(resultsByPubkey)
   };
 }
開發者ID:duniter,項目名稱:duniter,代碼行數:62,代碼來源:wot.ts

示例10: threads

 .subscribe((threadIdx: { [key: string]: Thread }) => {
     const threads = _.values(threadIdx);
     const threadNames = _.map(threads, (t: Thread) => t.name);
     console.log(` => threads (${threads.length}: ${threadNames}`);
 });
開發者ID:pietro909,項目名稱:angular-2-chat,代碼行數:5,代碼來源:thread.service.spec.ts


注:本文中的underscore.values函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。