How to use the inferno-shared.isArray function in inferno-shared

To help you get started, we’ve selected a few inferno-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jhsware / inferno-bootstrap / src / compat.js View on Github external
toArray: function (children) {
    if (isNullOrUndef(children)) {
      return [];
    }
    // We need to flatten arrays here,
    // because React does it also and application level code might depend on that behavior
    if (isArray(children)) {
      const result = [];

      flatten(children, result);

      return result;
    }
    return ARR.concat(children);
  }
};
github infernojs / inferno / packages / inferno-router / src / createRoutes.ts View on Github external
const node: IPlainRouteConfig = {} as IPlainRouteConfig;
  for (const key in routeConfigNode) {
    node[key] = routeConfigNode[key];
  }

  node.children = [];

  // handle index route config
  if (node.indexRoute) {
    node.children.push(handleIndexRoute(node.indexRoute));
    delete node.indexRoute;
  }

  // handle child routes config
  if (node.childRoutes) {
    const nodes: IPlainRouteConfig[] = isArray(node.childRoutes)
      ? node.childRoutes
      : [node.childRoutes];
    node.children.push(...handleChildRoutes(nodes));
    delete node.childRoutes;
  }

  // cleanup to match native rendered result
  if (node.children.length === 1) {
    node.children = node.children[0];
  }
  if (
    (isArray(node.children) && node.children.length === 0) ||
    (!isArray(node.children) && Object.keys(node.children).length === 0)
  ) {
    delete node.children;
  }
github infernojs / inferno / packages / inferno-router / src / createRoutes.ts View on Github external
// handle child routes config
  if (node.childRoutes) {
    const nodes: IPlainRouteConfig[] = isArray(node.childRoutes)
      ? node.childRoutes
      : [node.childRoutes];
    node.children.push(...handleChildRoutes(nodes));
    delete node.childRoutes;
  }

  // cleanup to match native rendered result
  if (node.children.length === 1) {
    node.children = node.children[0];
  }
  if (
    (isArray(node.children) && node.children.length === 0) ||
    (!isArray(node.children) && Object.keys(node.children).length === 0)
  ) {
    delete node.children;
  }

  return createElement(Route, node);
}
github infernojs / inferno / packages / inferno-router / src / Switch.ts View on Github external
function extractMatchFromChildren(children, route, location) {
  let match;
  let _child: any;

  if (isArray(children)) {
    for (let i = 0; i < children.length; ++i) {
      _child = children[i];

      if (isArray(_child)) {
        const nestedMatch = extractMatchFromChildren(_child, route, location);
        match = nestedMatch.match;
        _child = nestedMatch._child;
      } else {
        match = getMatch(_child.props, route, location);
      }

      if (match) {
        break;
      }
    }
  } else {