本文整理汇总了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')
示例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';