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

TypeScript lodash.isEmpty函数代码示例

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

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



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

示例1: setEditMode

angular.module("eperusteApp").factory("Editointikontrollit", ($rootScope, $q, Utils, Notifikaatiot,
                                                              YleinenData, $uibModal) => {
    let scope = $rootScope.$new(true);
    scope.editingCallback = null;
    scope.editMode = false;

    scope.editModeDefer = $q.defer();

    let cbListener = _.noop;
    let editmodeListener = null;

    async function setEditMode(mode) {
        scope.editMode = mode;
        scope.editModeDefer = $q.defer();
        scope.editModeDefer.resolve(scope.editMode);
        if (scope.editingCallback) {
            scope.editingCallback.notify(mode);
        }
        if (editmodeListener) {
            editmodeListener(mode);
        }
    }

    return {
        lastModified: null,
        async startEditing() {
            try {
                await scope.editingCallback.edit();
                setEditMode(true);
                $rootScope.$broadcast("enableEditing");
                $rootScope.$$ekEditing = true;
            } catch (ex) {
                $rootScope.$$ekEditing = false;
            }
        },

        notifySentenceCaseWarnings(obj) {
            const warnings = [];
            _.each(obj.paths, path => {
                this.sentenceCaseValidator(_.get(obj.obj, path), warnings);
            });
            if (warnings.length > 0) {
                $uibModal.open({
                    template: require("views/modals/sisaltoMuotoiluVaroitusModal.html"),
                    resolve: {
                        warnings: () => warnings
                    },
                    controller: ($scope, $uibModalInstance, warnings) => {
                        $scope.warnings = warnings;
                        $scope.ok = () => {
                            $uibModalInstance.close();
                        };
                        $scope.cancel = () => {
                            $uibModalInstance.dismiss('cancel');
                        };
                    },
                }).result.then(() => {
                    if (_.isFunction(obj.after)) {
                            obj.after();
                    }
                });
            } else {
                if (_.isFunction(obj.after)) {
                    obj.after();
                }
            }
        },

        sentenceCaseValidator(obj, warnings) {
            function validateSentenceCase(input, lang?) {
                const isValid = _.isEmpty(input) || (_.isString(input) && _.eq(input, _.capitalize(input.toLowerCase())));
                if (!isValid) {
                    warnings.push({
                        text: input,
                        lang
                    });
                }
                return isValid;
            }

            if (_.isObject(obj) && !_.isEmpty(obj)) {
                const langs = _(obj)
                    .keys()
                    .filter(key => _.includes(_.values(YleinenData.kielet), key))
                    .value();

                _.each(langs, (key: any) => {
                    validateSentenceCase(obj[key], key)
                });

            } else {
                validateSentenceCase(obj)
            }
        },

        async saveEditing(kommentti) {
            $rootScope.$broadcast("editointikontrollit:preSave");
            $rootScope.$broadcast("notifyCKEditor");
            let err;

//.........这里部分代码省略.........
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:101,代码来源:editointikontrollit.ts


示例2: emptyXOR

function emptyXOR(foo: any, bar: any): boolean {
  return (_.isEmpty(foo) || _.isEmpty(bar)) && !(_.isEmpty(foo) && _.isEmpty(bar));
}
开发者ID:connection-reset,项目名称:grafana,代码行数:3,代码来源:heatmap_data_converter.ts


示例3: isValidSignature

import { ECSignature } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';

import { signatureUtils } from '../utils/signature_utils';

export const assert = {
    ...sharedAssert,
    isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
        const isValidSignature = signatureUtils.isValidSignature(orderHash, ecSignature, signerAddress);
        this.assert(isValidSignature, `Expected order with hash '${orderHash}' to have a valid signature`);
    },
    async isSenderAddressAsync(
        variableName: string,
        senderAddressHex: string,
        web3Wrapper: Web3Wrapper,
    ): Promise<void> {
        sharedAssert.isETHAddressHex(variableName, senderAddressHex);
        const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex);
        sharedAssert.assert(
            isSenderAddressAvailable,
            `Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
        );
    },
    async isUserAddressAvailableAsync(web3Wrapper: Web3Wrapper): Promise<void> {
        const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
        this.assert(!_.isEmpty(availableAddresses), 'No addresses were available on the provided web3 provider');
    },
};
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:30,代码来源:assert.ts


示例4: require

import isMobile = require('is-mobile');
import * as _ from 'lodash';
import { scroller } from 'react-scroll';

import { EtherscanLinkSuffixes, Networks } from '../types';

import { constants } from './constants';

export const utils = {
    setUrlHash(anchorId: string) {
        window.location.hash = anchorId;
    },
    scrollToHash(hash: string, containerId: string): void {
        let finalHash = hash;
        if (_.isEmpty(hash)) {
            finalHash = constants.SCROLL_TOP_ID; // scroll to the top
        }

        scroller.scrollTo(finalHash, {
            duration: 0,
            offset: 0,
            containerId,
        });
    },
    isUserOnMobile(): boolean {
        const isUserOnMobile = isMobile();
        return isUserOnMobile;
    },
    getIdFromName(name: string) {
        const id = name.replace(/ /g, '-');
        return id;
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:utils.ts


示例5: return

 var queries = _.filter(options.targets, item => {
   return (
     item.hide !== true && !!item.region && !!item.namespace && !!item.metricName && !_.isEmpty(item.statistics)
   );
 }).map(item => {
开发者ID:knoguchi,项目名称:grafana,代码行数:5,代码来源:datasource.ts


示例6: getTrackedTokensByUserAddress

     let trackedTokensByNetworkId = trackedTokensByUserAddress[userAddress];
     if (_.isUndefined(trackedTokensByNetworkId)) {
         trackedTokensByNetworkId = {};
     }
     const trackedTokens = !_.isUndefined(trackedTokensByNetworkId[networkId])
         ? trackedTokensByNetworkId[networkId]
         : [];
     trackedTokens.push(token);
     trackedTokensByNetworkId[networkId] = trackedTokens;
     trackedTokensByUserAddress[userAddress] = trackedTokensByNetworkId;
     const trackedTokensByUserAddressJSONString = JSON.stringify(trackedTokensByUserAddress);
     localStorage.setItem(TRACKED_TOKENS_KEY, trackedTokensByUserAddressJSONString);
 },
 getTrackedTokensByUserAddress(): TrackedTokensByUserAddress {
     const trackedTokensJSONString = localStorage.getItemIfExists(TRACKED_TOKENS_KEY);
     if (_.isEmpty(trackedTokensJSONString)) {
         return {};
     }
     const trackedTokensByUserAddress = JSON.parse(trackedTokensJSONString);
     return trackedTokensByUserAddress;
 },
 getTrackedTokensByAddress(userAddress: string, networkId: number): TokenByAddress {
     const trackedTokensByAddress: TokenByAddress = {};
     const trackedTokensJSONString = localStorage.getItemIfExists(TRACKED_TOKENS_KEY);
     if (_.isEmpty(trackedTokensJSONString)) {
         return trackedTokensByAddress;
     }
     const trackedTokensByUserAddress = JSON.parse(trackedTokensJSONString);
     const trackedTokensByNetworkId = trackedTokensByUserAddress[userAddress];
     if (_.isUndefined(trackedTokensByNetworkId)) {
         return trackedTokensByAddress;
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:tracked_token_storage.ts


示例7: function

  this.query = function(options) {
    var self = this;
    var start = this.getPrometheusTime(options.range.from, false);
    var end = this.getPrometheusTime(options.range.to, true);

    var queries = [];
    var activeTargets = [];

    options = _.clone(options);

    _.each(options.targets, target => {
      if (!target.expr || target.hide) {
        return;
      }

      activeTargets.push(target);

      var query: any = {};
      query.expr = templateSrv.replace(target.expr, options.scopedVars, self.interpolateQueryExpr);
      query.requestId = options.panelId + target.refId;

      var interval = templateSrv.replace(target.interval, options.scopedVars) || options.interval;
      var intervalFactor = target.intervalFactor || 1;
      target.step = query.step = this.calculateInterval(interval, intervalFactor);
      var range = Math.ceil(end - start);
      // Prometheus drop query if range/step > 11000
      // calibrate step if it is too big
      if (query.step !== 0 && range / query.step > 11000) {
        target.step = query.step = Math.ceil(range / 11000);
      }

      queries.push(query);
    });

    // No valid targets, return the empty result to save a round trip.
    if (_.isEmpty(queries)) {
      var d = $q.defer();
      d.resolve({ data: [] });
      return d.promise;
    }

    var allQueryPromise = _.map(queries, query => {
      return this.performTimeSeriesQuery(query, start, end);
    });

    return $q.all(allQueryPromise).then(function(allResponse) {
      var result = [];

      _.each(allResponse, function(response, index) {
        if (response.status === 'error') {
          self.lastErrors.query = response.error;
          throw response.error;
        }
        delete self.lastErrors.query;
        _.each(response.data.data.result, function(metricData) {
          result.push(self.transformMetricData(metricData, activeTargets[index], start, end));
        });
      });

      return { data: result };
    });
  };
开发者ID:sis-labs,项目名称:grafana,代码行数:62,代码来源:datasource.ts


示例8: function

 !_.every(mustHave, function(item) {
   return (
     _.includes(keys, item) &&
     (!_.isEmpty(opts[item]) || _.isNumber(opts[item]))
   );
 })
开发者ID:pocesar,项目名称:node-stratum,代码行数:6,代码来源:daemon.ts


示例9: addYAxis

  addYAxis() {
    let ticks = Math.ceil(this.chartHeight / DEFAULT_Y_TICK_SIZE_PX);
    let tickInterval = ticksUtils.tickStep(this.data.heatmapStats.min, this.data.heatmapStats.max, ticks);
    let { yMin, yMax } = this.wideYAxisRange(this.data.heatmapStats.min, this.data.heatmapStats.max, tickInterval);

    // Rewrite min and max if it have been set explicitly
    yMin = this.panel.yAxis.min !== null ? this.panel.yAxis.min : yMin;
    yMax = this.panel.yAxis.max !== null ? this.panel.yAxis.max : yMax;

    // Adjust ticks after Y range widening
    tickInterval = ticksUtils.tickStep(yMin, yMax, ticks);
    ticks = Math.ceil((yMax - yMin) / tickInterval);

    const decimalsAuto = ticksUtils.getPrecision(tickInterval);
    let decimals = this.panel.yAxis.decimals === null ? decimalsAuto : this.panel.yAxis.decimals;
    // Calculate scaledDecimals for log scales using tick size (as in jquery.flot.js)
    const flotTickSize = ticksUtils.getFlotTickSize(yMin, yMax, ticks, decimalsAuto);
    const scaledDecimals = ticksUtils.getScaledDecimals(decimals, flotTickSize);
    this.ctrl.decimals = decimals;
    this.ctrl.scaledDecimals = scaledDecimals;

    // Set default Y min and max if no data
    if (_.isEmpty(this.data.buckets)) {
      yMax = 1;
      yMin = -1;
      ticks = 3;
      decimals = 1;
    }

    this.data.yAxis = {
      min: yMin,
      max: yMax,
      ticks: ticks,
    };

    this.scope.yScale = this.yScale = d3
      .scaleLinear()
      .domain([yMin, yMax])
      .range([this.chartHeight, 0]);

    const yAxis = d3
      .axisLeft(this.yScale)
      .ticks(ticks)
      .tickFormat(this.tickValueFormatter(decimals, scaledDecimals))
      .tickSizeInner(0 - this.width)
      .tickSizeOuter(0)
      .tickPadding(Y_AXIS_TICK_PADDING);

    this.heatmap
      .append('g')
      .attr('class', 'axis axis-y')
      .call(yAxis);

    // Calculate Y axis width first, then move axis into visible area
    const posY = this.margin.top;
    const posX = this.getYAxisWidth(this.heatmap) + Y_AXIS_TICK_PADDING;
    this.heatmap.select('.axis-y').attr('transform', 'translate(' + posX + ',' + posY + ')');

    // Remove vertical line in the right of axis labels (called domain in d3)
    this.heatmap
      .select('.axis-y')
      .select('.domain')
      .remove();
  }
开发者ID:bergquist,项目名称:grafana,代码行数:64,代码来源:rendering.ts


示例10: isValid

 public isValid(value: string): boolean {
     return !_.isEmpty(value);
 }
开发者ID:bovandersteene,项目名称:rbo-validate,代码行数:3,代码来源:RequireValidator.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.isEqual函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.isElement函数代码示例发布时间: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