本文整理汇总了TypeScript中@ephox/katamari.Arr.partition方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Arr.partition方法的具体用法?TypeScript Arr.partition怎么用?TypeScript Arr.partition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Arr
的用法示例。
在下文中一共展示了Arr.partition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
Futures.par(Arr.map(urls, loadF)).get(function (result) {
const parts = Arr.partition(result, function (r) {
return r.isValue();
});
if (parts.fail.length > 0) {
failure(parts.fail.map(unbox));
} else {
success(parts.pass.map(unbox));
}
});
示例2: function
const add = (id: string, addOn: (editor: Editor, url: string) => any, dependencies?) => {
items.push(addOn);
lookup[id] = { instance: addOn, dependencies };
const result = Arr.partition(_listeners, function (listener) {
return listener.name === id;
});
_listeners = result.fail;
each(result.pass, function (listener) {
listener.callback();
});
return addOn;
};
示例3: makeGroup
const renderComponents = (_data, state) => {
// default group is 'end'
const footerButtons = state.map((s) => s.footerButtons).getOr([ ]);
const buttonGroups = Arr.partition(footerButtons, (button) => button.align === 'start');
const makeGroup = (edge, buttons): SketchSpec => Container.sketch({
dom: {
tag: 'div',
classes: [ `tox-dialog__footer-${edge}` ]
},
components: Arr.map(buttons, (button) => button.memento.asSpec())
});
const startButtons = makeGroup('start', buttonGroups.pass);
const endButtons = makeGroup('end', buttonGroups.fail);
return [ startButtons, endButtons ];
};
示例4: add
* });
*
* // Register plugin using the add method
* tinymce.PluginManager.add('test', tinymce.plugins.TestPlugin);
*
* // Initialize TinyMCE
* tinymce.init({
* ...
* plugins: '-test' // Init the plugin but don't try to load it
* });
*/
add (id, addOn, dependencies) {
this.items.push(addOn);
this.lookup[id] = { instance: addOn, dependencies };
const result = Arr.partition(this._listeners, function (listener) {
return listener.name === id;
});
this._listeners = result.fail;
each(result.pass, function (listener) {
listener.callback();
});
return addOn;
},
remove (name) {
delete this.urls[name];
delete this.lookup[name];
},