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


TypeScript has.add函数代码示例

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


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

示例1: decodeURIComponent

import global from '@dojo/shim/global';
import has, { add as hasAdd } from '@dojo/has/has';

hasAdd('btoa', 'btoa' in global, true);
hasAdd('atob', 'atob' in global, true);

/**
 * Take a string encoded in base64 and decode it
 * @param encodedString The base64 encoded string
 */
export const decode: (encodedString: string) => string = has('atob')
	? function(encodedString: string) {
			/* this allows for utf8 characters to be decoded properly */
			return decodeURIComponent(
				Array.prototype.map
					.call(
						atob(encodedString),
						(char: string) => '%' + ('00' + char.charCodeAt(0).toString(16)).slice(-2)
					)
					.join('')
			);
		}
	: function(encodedString: string): string {
			return new Buffer(encodedString.toString(), 'base64').toString('utf8');
		};

/**
 * Take a string and encode it to base64
 * @param rawString The string to encode
 */
export const encode: (rawString: string) => string = has('btoa')
开发者ID:jason0x43,项目名称:core,代码行数:31,代码来源:base64.ts

示例2: add

import has, { add } from '@dojo/has/has';
import '@dojo/test-extras/support/loadJsdom';
import './util';

add('touch', () => {
	/* Since jsdom will fake it anyways, no problem pretending we can do touch in NodeJS */
	return Boolean('ontouchstart' in window || has('host-node'));
});

import '../../../accordionpane/tests/unit/AccordionPane';
import '../../../button/tests/unit/Button';
import '../../../calendar/tests/unit/Calendar';
import '../../../calendar/tests/unit/CalendarCell';
import '../../../calendar/tests/unit/DatePicker';
import '../../../checkbox/tests/unit/Checkbox';
import '../../../combobox/tests/unit/ComboBox';
import '../../../dialog/tests/unit/Dialog';
import '../../../label/tests/unit/Label';
import '../../../listbox/tests/unit/Listbox';
import '../../../listbox/tests/unit/ListboxOption';
import '../../../radio/tests/unit/Radio';
import '../../../select/tests/unit/Select';
import '../../../slidepane/tests/unit/SlidePane';
import '../../../slider/tests/unit/Slider';
import '../../../splitpane/tests/unit/SplitPane';
import '../../../tabcontroller/tests/unit/Tab';
import '../../../tabcontroller/tests/unit/TabButton';
import '../../../tabcontroller/tests/unit/TabController';
import '../../../textarea/tests/unit/Textarea';
import '../../../textinput/tests/unit/TextInput';
import '../../../timepicker/tests/unit/TimePicker';
开发者ID:bitpshr,项目名称:widgets,代码行数:31,代码来源:all.ts


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