How to use the ix.Iterable.from function in ix

To help you get started, we’ve selected a few ix 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 Polymer / tools / packages / modulizer / src / document-util.ts View on Github external
export function getCommentsBetween(
    document: parse5.ASTNode,
    from: parse5.ASTNode|undefined,
    until: parse5.ASTNode|undefined): string[] {
  const nodesStart =
      from === undefined ? nodesInside(document) : nodesAfter(from);
  const nodesBetween =
      IterableX.from(nodesStart).takeWhile((node) => node !== until);
  const commentNodesBetween =
      nodesBetween.filter((node) => dom5.isCommentNode(node));
  const commentStringsBetween =
      commentNodesBetween.map((node) => dom5.getTextContent(node));
  const formattedCommentStringsBetween =
      commentStringsBetween.map((commentText) => {
        // If it looks like there might be jsdoc in the comment, start the
        // comment with an extra * so that the js comment looks like a jsdoc
        // comment.
        if (/@\w+/.test(commentText)) {
          return '*' + commentText;
        }
        return commentText;
      });
  return Array.from(formattedCommentStringsBetween);
}
github marinels / webrx-react / src / Components / Common / ListItems / GridView.tsx View on Github external
protected getColumnDefinitions(): Array | undefined {
    const count = React.Children.count(this.props.children);

    if (count === 0) {
      // try and auto-gen columns
      const item = this.getListItems().getItems().first();

      if (item == null) {
        this.logger.warn('Unable to Autogenerate Columns');

        return undefined;
      }

      return Iterable
        .from(Object.keys(item))
        .orderBy(x => x)
        .map(x => (
          
        ))
        .toArray();
    }

    if (count === 1) {
      const elem = React.Children.only(this.props.children);

      if (React.isType(elem, GridViewColumns)) {
        return React.Children.toArray(elem.props.children);
      }
    }
github Polymer / tools / src / document-converter.ts View on Github external
},
        });
      }
    }
    const usedIdentifiers = collectIdentifierNames(program, ignoredIdentifiers);

    const jsExplicitImports = new Set();
    // Rewrite HTML Imports to JS imports
    const jsImportDeclarations = [];
    for (const htmlImport of this.getHtmlImports()) {
      const importedJsDocumentUrl = this.convertDocumentUrl(
          this.urlHandler.getDocumentUrl(htmlImport.document));

      const references = importedReferences.get(importedJsDocumentUrl);
      const namedExports =
          new Set(IterableX.from(references || []).map((ref) => ref.target));

      const jsFormattedImportUrl =
          this.formatImportUrl(importedJsDocumentUrl, htmlImport.originalUrl);
      jsImportDeclarations.push(...getImportDeclarations(
          jsFormattedImportUrl, namedExports, references, usedIdentifiers));

      jsExplicitImports.add(importedJsDocumentUrl);
    }
    // Add JS imports for any additional, implicit HTML imports
    for (const jsImplicitImportUrl of importedReferences.keys()) {
      if (jsExplicitImports.has(jsImplicitImportUrl)) {
        continue;
      }

      const references = importedReferences.get(jsImplicitImportUrl);
      const namedExports =
github Polymer / tools / src / tools / test-polymer.ts View on Github external
}

  const options = {
    inDir: sourceDir,
    outDir: sourceDir,
    packageName: '@polymer/polymer',
    packageVersion: '3.0.0',
  };
  const analyzer = configureAnalyzer(options);
  const analysis = await analyzer.analyzePackage();
  const converter = configureConverter(analysis, options);
  const results = await converter.convert();
  const resultPaths = IterableX.from(results.entries())
                          .filter(([_, v]) => v !== undefined)
                          .map(([k]) => k);
  const expectedPaths = IterableX.from(walkDir(expectedDir))
                            .map((f) => f as ConvertedDocumentFilePath)
                            .filter((f) => f !== './package.json');
  const allPathsUnsorted = new Set(resultPaths.concat(expectedPaths));
  const allPaths = [...allPathsUnsorted].sort((a, b) => a.localeCompare(b));
  for (const outPath of allPaths) {
    const jsContents = results.get(outPath);
    if (jsContents === undefined) {
      exitCode = 1;
      console.log(chalk.bold.red(`✕ ${outPath} (missing file)`));
      continue;
    }
    const expectedJsPath = path.resolve(expectedDir, outPath);
    let expectedJsContents;
    try {
      expectedJsContents = fs.readFileSync(expectedJsPath, 'utf8');
    } catch (e) {
github marinels / webrx-react / src / Components / Common / ListItems / ListItemsViewModel.ts View on Github external
      .toProperty([], (a, b) => Iterable.from(a).sequenceEqual(Iterable.from(b)));
github marinels / webrx-react / src / Components / Common / DataGrid / DataGridViewModel.ts View on Github external
protected getResponse(request: DataSourceRequest | undefined): ObservableOrValue | undefined> {
    if (request == null) {
      return undefined;
    }

    const items = Iterable
      .from(this.source.value);

    return this.getResponseFromItems(items, request);
  }
github marinels / webrx-react / src / Components / Common / ListItems / GridView.tsx View on Github external
protected renderTableHeaderRow() {
    if (this.columns == null) {
      return undefined;
    }

    const renderHeaders = Iterable
      .from(this.columns)
      .some(x => GridViewColumn.canRenderHeader(x));

    if (renderHeaders) {
      const props = this.trimProps({
        itemTemplate: this.props.headerTemplate,
      });

      return (
        
          {
            this.columns
              .map(x => {
                if (React.isValidElement(x)) {
                  return (
github Polymer / tools / src / conversion-settings.ts View on Github external
function getNamespaceNames(analysis: Analysis) {
  return IterableX
      .from(analysis.getFeatures(
          {kind: 'namespace', externalPackages: true, imported: true}))
      .map((n) => {
        const name = n.name;
        if (name.startsWith('window.')) {
          return name.slice('window.'.length);
        }
        return name;
      });
}
github marinels / webrx-react / src / Components / Common / ListItems / TreeListItemsViewModel.ts View on Github external
getItems() {
    return Iterable
      .from(this.getItemsSource())
      .flatMap(x => this.flattenItems(x));
  }
github marinels / webrx-react / src / Components / Common / ListItems / TreeListItemsViewModel.ts View on Github external
export function flattenItems(
  item: T,
  itemsSource: (item: T) => (IterableLike | undefined),
): Iterable {
  const items = itemsSource(item);

  return items == null ?
    Iterable.of(item) :
    Iterable
      .from(items)
      .flatMap(x => flattenItems(x, itemsSource))
      .startWith(item);
}