How to use the immutable.Range function in immutable

To help you get started, we’ve selected a few immutable 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 reindexio / reindex-api / db / rethinkdb / queries / __tests__ / connectionQueries.js View on Github external
assert.oequal(
            await runAndGivePositions(indexes, {
              orderBy: { field: 'createdAt' },
              before: cursors.get(2),
            }),
            Range(0, 2),
            'only before'
          );

          assert.oequal(
            await runAndGivePositions(indexes, {
              orderBy: { field: 'createdAt' },
              after: cursors.get(1),
              before: cursors.get(5),
            }),
            Range(2, 5),
            'before and after'
          );

          // XXX(freiksenet, 2015-08-12): this is not strictly compliant to
          // relay spec, that asks to not apply one of the cursors if they are
          // disjoint.
          assert.oequal(
            await runAndGivePositions(indexes, {
              orderBy: { field: 'createdAt' },
              before: cursors.get(1),
              after: cursors.get(5),
            }),
            List(),
            'disjoint before and after'
          );
        });
github StratoDem / pandas-js / src / es6 / core / frame.js View on Github external
if (data instanceof Immutable.Map)
          return [k, data.get(k).copy()];

        throw new Error('Data is not Map');
      }));
      this.set_axis(1, this._data.keySeq());
      this.set_axis(0, this._data.get(this.columns.get(0)).index);
    } else if (data instanceof Immutable.List) { // List of List of row values
      let columns;
      if (Array.isArray(kwargs.columns) || kwargs.columns instanceof Immutable.Seq)
        columns = Immutable.List(kwargs.columns);
      else if (kwargs.columns instanceof Immutable.List)
        columns = kwargs.columns;
      else if (typeof kwargs.columns === 'undefined')
        columns = Immutable.Range(0, data.get(0).size).toList();
      else
        throw new Error('Invalid columns');

      this._values = data; // Cache the values since we're in List of List or row data already
      this._data = Immutable.OrderedMap(columns.map((c, colIdx) =>
        ([c, new Series(data.map(row => row.get(colIdx)), {index: kwargs.index})])));

      this.set_axis(1, this._data.keySeq());
      this.set_axis(0, this._data.get(this.columns.get(0)).index);
    } else if (typeof data === 'undefined') {
      this._data = Immutable.Map({});
      this.set_axis(0, Immutable.List.of());
      this.set_axis(1, Immutable.Seq.of());
    }

    this._setup_axes(Immutable.List.of(0, 1));
github cooperka / react-native-immutable-list-view / example / src / ImmutableListViewExample.js View on Github external
function ImmutableListViewExample() {
  return (
     data.setIn(['Section A', 1], 'This value was changed!')}
      extraPropsA={{
        renderSectionHeader: utils.renderSectionHeader,
      }}

      initialDataB={Immutable.Range(1, 100)}
      dataMutatorB={(data) => data.toSeq().map((n) => n * 2)}
    />
  );
}
github blueberryapps / haystack / src / browser / OurWork / zaploDk / index.js View on Github external
renderPhotos() {
    const { msg } = this.props;
    const photosArray = Range(1, 17).map(i => this.renderPhoto(i));

    return (
      
        <img style="{styles.photos.cooperation}" src="{require('./images/cooperation.png')}" alt="{msg('Coopertion')}">
        <div style="{styles.photos.innerWrapper}">
          {photosArray}
        </div>
      
    );
  }
github hoppinger / MonadicReact / samples / Client / samples / list.ts View on Github external
import * as React from "react"
import * as ReactDOM from "react-dom"
import {List, Map, Set, Range} from "immutable"
import * as Immutable from "immutable"
import * as Moment from 'moment'
import {UrlTemplate, application, get_context, Route, Url, make_url, fallback_url, link_to_route,
Option, C, Mode, unit, bind, string, number, bool, button, selector, multi_selector, label, h1, h2, div, form, image, link, file, overlay,
custom, repeat, all, any, lift_promise, retract, delay,
simple_menu, mk_menu_entry, mk_submenu_entry, MenuEntry, MenuEntryValue, MenuEntrySubMenu,
rich_text, paginate, Page, list, editable_list} from '../../../src/monadic_react'

export let list_sample : C =
  list(Range(1,10).toList(), `list sample`)(
    i =&gt; n =&gt; string("view", "text", `item-${i}-${n}`)(`This is item ${i}/${n}`).ignore(`ignore-${i}-${n}`)
  )
github hoppinger / MonadicReact / samples / Client / samples / tabbed menu.tsx View on Github external
import * as React from "react"
import * as ReactDOM from "react-dom"
import {List, Map, Set, Range} from "immutable"
import * as Immutable from "immutable"
import {UrlTemplate, application, get_context, Route, Url, make_url, fallback_url, link_to_route,
Option, C, Mode, unit, bind, string, number, bool, button, selector, multi_selector, label, h1, h2, div, form, image, link, file, overlay,
custom, repeat, all, any, lift_promise, retract, delay,
simple_menu, mk_menu_entry, mk_submenu_entry, MenuEntry, MenuEntryValue, MenuEntrySubMenu,
rich_text, paginate, Page, list, editable_list} from '../../../src/monadic_react'

type FictionalPage = { title:string, content:string }

export let tabbed_menu_sample : C =
  simple_menu({kind:"tabs",max_tabs:5}, p =&gt; p.title, `tabbed menu`)(
    Range(1, 10).map(i =&gt;
      ({ title:`Tab ${i}`, content:`This is the content of the tab ${i}.`})
    ).map&gt;(s =&gt; ({ kind:"item", value:s})).toArray(),
    p =&gt; string("view")(p.content)
  ).ignore()
github dvalchanov / react-redux-2048 / src / scripts / reducers / Game.js View on Github external
function findAvailableCell(state, tile, direction) {
  let available;
  const {axis, value} = getCurrent(direction);
  const from = tile.get(axis);
  const to = value &lt; 0 ? (SIZE - 1) : 0;

  Range(to, from).forEach(index =&gt; {
    const path = (
      axis === "x" ?
      ["grid", index, tile.get("y")] :
      ["grid", tile.get("x"), index]
    );

    const cell = state.getIn(path);

    if (!isSuitable(cell, tile)) {
      available = null;
      return;
    }

    if (tile.get("value") === "x") {
      if (cell.size === 1 || (!cell.size &amp;&amp; !available)) available = path;
    } else {
github staltz / flux-challenge / submissions / ds300 / src / model.js View on Github external
function _modifySithIDs(state, n, f) {
    var sithIDs = state.sithIDs;
    immutable_1.Range(0, n).forEach(function () {
        sithIDs = f(sithIDs);
    });
    return cleanCache(discoverSiths(util_1.assoc(state, { sithIDs: sithIDs })));
}
function down(state, n) {
github gnoff / react-everscroll / index.js View on Github external
_getKeyList: function() {
    var keyStart = this.state.keyStart;
    var basicRange = Immutable.Range(0, this.props.renderCount);

    return basicRange.slice(keyStart).toList().concat(basicRange.slice(0, keyStart).toList())
  },
github macarthur-lab / gnomadjs / packages / api / deploy / precache_genes.js View on Github external
function splitIntoGroups(list, chunkSize) {
    return Range(0, list.count(), chunkSize)
      .map(chunkStart => list.slice(chunkStart, chunkStart + chunkSize))
  }