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