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


TypeScript underscore.defaults函数代码示例

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


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

示例1: runProfile

    async runProfile(profile: IProfile, sessionOutput: ISessionOutput, cancellationToken?: ICancellationToken): Promise<any> {
        _.defaults(profile, this.defaultProfile);

        const runner = new ProfileRunner(profile, sessionOutput);

        return await runner.run(cancellationToken);
    }
开发者ID:pumlhorse,项目名称:pumlhorse,代码行数:7,代码来源:App.ts

示例2: constructor

    constructor(listOptions: ListOptions<TModel>, viewOptions?: Backbone.ViewOptions<TModel>) {

        let behaviors: any = [];

        if (listOptions.sortable){
            behaviors = [{
                  behaviorClass: SortableBehavior
                }
              ];
        }

        super($.extend(viewOptions, {
            className: "list-group list-group-get4",
            collection: listOptions.collection,
            childView: listOptions.childView,
            behaviors: behaviors
        }));

        this.options = _.defaults(listOptions, {
            sortable: false
        });

        let self = this;

        this.listenTo(this.collection, "before:fetch", () => {
            self.triggerMethod('load:start');
        });
    };
开发者ID:luk156,项目名称:get-ui,代码行数:28,代码来源:List.ts

示例3: updateTsd

		/**
		 * Recreate all tsd json files from repo data
		 */
		updateTsd(options:any, callback:(err?, res?:RecreateResult) => void) {

			options = _.defaults(options || {}, {
				parse: 'all',
				export: 'parsed'
			});

			var ret = new RecreateResult(this.repos, options);

			async.waterfall([(callback:(err) => void) => {
				//why compare? (split this into recreate new/changed/all)
				var comparer = new DefinitionComparer(this.repos);
				comparer.compare(callback);

			}, (compareResult:CompareResult, callback:(err?, res?:ImportResult) => void) => {
				if (!compareResult) return callback('DefinitionComparer.compare returned no result');

				ret.compareResult = compareResult;

				var importer = new DefinitionImporter(this.repos);
				var defs:Def[] = compareResult.repoAll;
				if (options.parse === 'new') {
					defs = compareResult.repoUnlisted;
				}
				ret.importSelection = defs;

				importer.parseDefinitions(defs, callback);

			}, (importResult:ImportResult, callback:(err?, res?:ExportResult) => void) => {
				if (!importResult) return callback('DefinitionImporter.parseDefinitions returned no result');

				ret.importResult = importResult;

				var exporter = new DefinitionExporter(this.repos, this.info);
				helper.removeFilesFromDir(exporter.repos.out, (err) => {
					if (err) return callback(err, null);

					var list:deftools.DefData[] = importResult.parsed;
					if (options.export === 'all') {
						list = importResult.all;
					}
					else if (options.export === 'error') {
						list = importResult.error;
					}
					ret.exportSelection = list;

					exporter.exportDefinitions(list, callback);

				});
			}], (err?, exportResult?:ExportResult) => {
				if (err) return callback(err);

				ret.exportResult = exportResult;

				callback(null, ret);
			});
		}
开发者ID:Bartvds,项目名称:tsd-deftools,代码行数:60,代码来源:api.ts

示例4: function

    self.setupTable = function (options: any) {
        // console.log('setupTable');
        let scrollXY: number[] = [];

        const optionsCopy = _.clone(options);
        const settings = _.defaults(optionsCopy, optionDefaults);

        const tableData: any = new fattable.SyncTableModel();
        const painter = new fattable.Painter();

        const headers = settings.headers;
        const rows = settings.rows;

        function get2dContext(font: any) {
            const canvas = document.createElement("canvas");
            document.createDocumentFragment().appendChild(canvas);
            const context = canvas.getContext("2d");
            context.font = font;
            return context;
        }

        const headerContext = get2dContext(settings.headerFontWeight + " " + settings.headerFontSize + " " + settings.headerFontFamily);
        const rowContext = get2dContext(settings.rowFontWeight + " " + settings.rowFontSize + " " + settings.rowFontFamily);

        tableData.columnHeaders = [];
        const columnWidths: number[] = [];
        _.each(headers, function (column) {
            const headerText = settings.headerText(column);
            const headerTextWidth = headerContext.measureText(headerText).width;
            const longestColumnText = _.reduce(rows, function (previousMax, row) {
                const cellText = settings.cellText(row, column);
                const cellTextLength = cellText === undefined || cellText === null ? 0 : cellText.length;
                return previousMax.length < cellTextLength ? cellText : previousMax;
            }, "");

            const columnTextWidth = rowContext.measureText(longestColumnText).width;
            columnWidths.push(Math.min(settings.maxColumnWidth, Math.max(settings.minColumnWidth, headerTextWidth, columnTextWidth)) + settings.padding);
            tableData.columnHeaders.push(headerText);
        });

        painter.setupHeader = function (div) {
            // console.log("setupHeader");
            const separator = angular.element('<div class="header-separator"></div>');
            separator.on("mousedown", event => mousedown(separator, event));

            const heading = angular.element('<div class="header-value ui-grid-header-cell-title"></div>');

            const headerDiv = angular.element(div);

            headerDiv.append(heading).append(separator);
        };

        painter.fillCell = function (div:any, data:any) {
            if (data === undefined) {
                return;
            }
            if (data.columnId === 0) {
                div.className = " first-column ";
            }
            div.style.fontSize = settings.rowFontSize;
            div.style.fontFamily = settings.rowFontFamily;
            div.className += "layout-column layout-align-center-start ";
            if (data["rowId"] % 2 === 0) {
                div.className += " even ";
            }
            else {
                div.className += " odd ";
            }
            settings.fillCell(div, data);
        };

        painter.fillHeader = function (div: any, header: any) {
            // console.log('fill header', header);
            div.style.fontSize = settings.headerFontSize;
            div.style.fontFamily = settings.headerFontFamily;
            div.style.fontWeight = settings.headerFontWeight;
            const children = angular.element(div).children();

            setColumnId(children.last(), header.id);

            const valueDiv = children.first();
            valueDiv.css("width", (self.table.columnWidths[header.id] - settings.headerPadding - 2) + "px"); //leave 2 pixels for column separator
            const valueSpan = valueDiv.get(0);
            settings.fillHeader(valueSpan, header);
        };

        tableData.getCellSync = function (i: any, j: any) {
            const data = settings.getCellSync(i, j);
            if (data !== undefined) {
                //add row id so that we can add odd/even classes to rows
                data.rowId = i;
                data.columnId = j;
            }
            return data;
        };

        tableData.getHeaderSync = function (j: any) {
            const header = settings.getHeaderSync(j);
            return {
                value: header,
//.........这里部分代码省略.........
开发者ID:prashanthc97,项目名称:kylo,代码行数:101,代码来源:FattableService.ts

示例5:

				console.log('hasDependency(): ' + res.hasDependency().length);
				console.log('countReferences(): ' + res.countReferences());
				console.log('countDependencies(): ' + res.countDependencies());
				console.log('isDependency(): ' + res.isDependency().length);
				console.log('dupeCheck(): ' + _.size(res.dupeCheck()));
				console.log('checkDupes():\n' + util.inspect(res.checkDupes(), false, 4));
			};
			//do it!
			if (args.project) {
				api.parseProject(args.project, reportParseStat);
			}
			else {
				api.parseAll(reportParseStat);
			}
		}, 'parse repo typing headers', _.defaults({
			project: '<project> : project selector'
		}, params));

		expose.add('updateTsd', (args:any) => {

			var options = {
				parse: args.parse,
				export: args.export
			};

			api.updateTsd(options, (err?, res?:deftools.RecreateResult) => {
				if (err) return console.log(err);
				if (!res) return console.log('updateTSD returned no result');

				write(args.write, res);
				if (args.dump) {
开发者ID:Bartvds,项目名称:tsd-deftools,代码行数:31,代码来源:deftools.ts


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