How to use the tsmonad.Maybe.just function in tsmonad

To help you get started, we’ve selected a few tsmonad 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 Simon-Initiative / authoring-client / src / editors / content / items / DynaDropTargetItems.tsx View on Github external
onScoreEdit(response: contentTypes.Response, score: string) {
    const {
      itemModel,
      partModel,
      onEdit,
    } = this.props;

    const updated = response.with({ score: Maybe.just(score) });
    const newPartModel = partModel.with(
      { responses: partModel.responses.set(updated.guid, updated) });
    onEdit(itemModel, newPartModel, updated);
  }
github Simon-Initiative / authoring-client / src / editors / content / question / imagehotspot / ImageHotspot.tsx View on Github external
onScoreEdit(response: contentTypes.Response, score: string) {
    const { partModel, itemModel, onEdit } = this.props;

    const updatedScore = response.with({
      score: score === '' ? Maybe.nothing() : Maybe.just(score),
    });
    const updatedPartModel = partModel.with(
      { responses: partModel.responses.set(updatedScore.guid, updatedScore) },
    );

    onEdit(itemModel, updatedPartModel, updatedPartModel);
  }
github Simon-Initiative / authoring-client / src / editors / content / part / NumericFeedback.tsx View on Github external
onScoreEdit(response: contentTypes.Response, score: string) {
    const { model, onEdit } = this.props;

    onEdit(model.with({
      responses: model.responses.set(
        response.guid,
        model.responses.get(response.guid).with({
          score: score === '' ? Maybe.nothing() : Maybe.just(score),
        }),
      ),
    }));
  }
github Simon-Initiative / authoring-client / src / editors / content / question / multiplechoice / MultipleChoice.tsx View on Github external
onScoreEdit(response: contentTypes.Response, score: string) {
    const { partModel, itemModel, onEdit } = this.props;

    const updatedScore = response.with({
      score: score === '' ? Maybe.nothing() : Maybe.just(score),
    });
    const updatedPartModel = partModel.with(
      { responses: partModel.responses.set(updatedScore.guid, updatedScore) },
    );

    onEdit(itemModel, updatedPartModel, updatedPartModel);
  }
github Simon-Initiative / authoring-client / src / editors / content / question / ordering / Ordering.tsx View on Github external
onScoreEdit = (response: contentTypes.Response, score: string) => {
    const { partModel } = this.props;

    this.onPartEdit(
      partModel.with({
        responses: partModel.responses.set(
          response.guid,
          response.with({
            score: score === '' ? Maybe.nothing() : Maybe.just(score),
          }),
        ),
      }),
      null,
    );
  }
github Simon-Initiative / authoring-client / src / data / content / learning / pullout.ts View on Github external
function fromStr(value: string): Maybe {
  switch (value) {
    case 'note': return Maybe.just(PulloutType.Note);
    case 'notation': return Maybe.just(PulloutType.Notation);
    case 'observation': return Maybe.just(PulloutType.Observation);
    case 'research': return Maybe.just(PulloutType.Research);
    case 'tip': return Maybe.just(PulloutType.Tip);
    case 'tosumup': return Maybe.just(PulloutType.ToSumUp);
    default: return Maybe.nothing();
  }
}
github Simon-Initiative / authoring-client / src / data / content / learning / dt.ts View on Github external
static fromPersistence(root: Object, guid: string, notify: () => void) : Dt {

    const t = (root as any).dt;

    let model = new Dt().with({ guid });

    if (t['@title'] !== undefined) {
      model = model.with({ title: Maybe.just(t['@title']) });
    }

    model = model.with({ content: ContentElements
      .fromPersistence(t, createGuid(), INLINE_ELEMENTS, null, notify) });

    return model;
  }
github Simon-Initiative / authoring-client / src / data / content / learning / anchor.ts View on Github external
static fromPersistence(root: Object, guid: string, notify: () => void): Anchor {
    const t = (root as any).anchor;

    let model = new Anchor({ guid });

    const children = getChildren(t);

    if (children instanceof Array
      && children.length === 1 && (children[0] as any).image !== undefined) {
      model = model.with({ content: Maybe.just(Image.fromPersistence(children[0], '', notify)) });
    }

    return model;
  }
github Simon-Initiative / authoring-client / src / data / content / learning / quote.ts View on Github external
static fromPersistence(root: Object, guid: string, notify: () => void) : Quote {

    const t = (root as any).quote;

    const text = ContentElements.fromPersistence(getChildren(t), '', TEXT_ELEMENTS, null, notify);
    const entry = t['@entry'] === undefined
      ? Maybe.nothing()
      : Maybe.just(t['@entry']);

    return new Quote().with({ guid, text, entry });

  }
github Simon-Initiative / authoring-client / src / data / content / learning / blockquote.ts View on Github external
static fromPersistence(root: Object, guid: string, notify: () => void) : BlockQuote {

    const t = (root as any).quote;

    const text = ContiguousText.fromPersistence(getChildren(t), '', ContiguousTextMode.SimpleText);

    const entry = t['@entry'] === undefined
      ? Maybe.nothing()
      : Maybe.just(t['@entry']);

    return new BlockQuote({ guid, text, entry });
  }

tsmonad

TsMonad - fun-size monads library for TypeScript

MIT
Latest version published 7 years ago

Package Health Score

51 / 100
Full package analysis

Popular tsmonad functions