當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。