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


TypeScript Tools.isArray函数代码示例

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


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

示例1: isEqual

// Todo: Maybe this should be shallow compare since it might be huge object references
function isEqual(a, b) {
  let k, checked;

  // Strict equals
  if (a === b) {
    return true;
  }

  // Compare null
  if (a === null || b === null) {
    return a === b;
  }

  // Compare number, boolean, string, undefined
  if (typeof a !== 'object' || typeof b !== 'object') {
    return a === b;
  }

  // Compare arrays
  if (Tools.isArray(b)) {
    if (a.length !== b.length) {
      return false;
    }

    k = a.length;
    while (k--) {
      if (!isEqual(a[k], b[k])) {
        return false;
      }
    }
  }

  // Shallow compare nodes
  if (isNode(a) || isNode(b)) {
    return a === b;
  }

  // Compare objects
  checked = {};
  for (k in b) {
    if (!isEqual(a[k], b[k])) {
      return false;
    }

    checked[k] = true;
  }

  for (k in a) {
    if (!checked[k] && !isEqual(a[k], b[k])) {
      return false;
    }
  }

  return true;
}
开发者ID:danielpunkass,项目名称:tinymce,代码行数:56,代码来源:ObservableObject.ts

示例2: function

  const stripAttribs = function ($el, attr) {
    if (Tools.isArray(attr)) {
      Tools.each(attr, function (attr) {
        stripAttribs($el, attr);
      });
      return;
    }

    $el.removeAttr(attr);
    $el.find('[' + attr + ']').removeAttr(attr);
  };
开发者ID:abstask,项目名称:tinymce,代码行数:11,代码来源:TocPluginTest.ts

示例3: function

const getToolbars = function (editor) {
  const toolbar = editor.getParam('toolbar');
  const defaultToolbar = 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image';

  if (toolbar === false) {
    return [];
  } else if (Tools.isArray(toolbar)) {
    return Tools.grep(toolbar, function (toolbar) {
      return toolbar.length > 0;
    });
  } else {
    return getIndexedToolbars(editor.settings, defaultToolbar);
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:14,代码来源:Settings.ts

示例4: function

const splitAndApply = function (editor, container, found, space) {
  const formatArray = Tools.isArray(found.pattern.format) ? found.pattern.format : [found.pattern.format];
  const validFormats = Tools.grep(formatArray, function (formatName) {
    const format = editor.formatter.get(formatName);
    return format && format[0].inline;
  });

  if (validFormats.length !== 0) {
    editor.undoManager.transact(function () {
      container = splitContainer(container, found.pattern, found.endOffset, found.startOffset, space);
      formatArray.forEach(function (format) {
        editor.formatter.apply(format, {}, container);
      });
    });

    return container;
  }
};
开发者ID:abstask,项目名称:tinymce,代码行数:18,代码来源:Formatter.ts

示例5: function

const createCustomMenuItems = function (editor, names) {
  let items, nameList;

  if (typeof names === 'string') {
    nameList = names.split(' ');
  } else if (Tools.isArray(names)) {
    return Arr.flatten(Tools.map(names, function (names) {
      return createCustomMenuItems(editor, names);
    }));
  }

  items = Tools.grep(nameList, function (name) {
    return name === '|' || name in editor.menuItems;
  });

  return Tools.map(items, function (name) {
    return name === '|' ? { text: '-' } : editor.menuItems[name];
  });
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:19,代码来源:InsertButton.ts

示例6: splitContainer

const splitAndApply = (editor: Editor, container, found, inline) => {
  const formatArray = Tools.isArray(found.pattern.format) ? found.pattern.format : [found.pattern.format];
  const validFormats = Tools.grep(formatArray, (formatName) => {
    const format = editor.formatter.get(formatName);
    return format && format[0].inline;
  });

  if (validFormats.length !== 0) {
    editor.undoManager.transact(() => {
      container = splitContainer(container, found.pattern, found.endOffset, found.startOffset);
      // The splitContainer function above moves the selection range in Safari
      // so we have to set it back to the next sibling, the nbsp behind the
      // split text node, when applying inline formats.
      if (inline) {
        editor.selection.setCursorLocation(container.nextSibling, 1);
      }
      formatArray.forEach((format) => {
        editor.formatter.apply(format, {}, container);
      });
    });

    return container;
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:24,代码来源:PatternApplication.ts

示例7: add

      this.add(items);
    }
  },

  /**
   * Adds new items to the control collection.
   *
   * @method add
   * @param {Array} items Array if items to add to collection.
   * @return {tinymce.ui.Collection} Current collection instance.
   */
  add (items) {
    const self = this;

    // Force single item into array
    if (!Tools.isArray(items)) {
      if (items instanceof Collection) {
        self.add(items.toArray());
      } else {
        push.call(self, items);
      }
    } else {
      push.apply(self, items);
    }

    return self;
  },

  /**
   * Sets the contents of the collection. This will remove any existing items
   * and replace them with the ones specified in the input array.
开发者ID:danielpunkass,项目名称:tinymce,代码行数:31,代码来源:Collection.ts


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