How to use timm - 10 common examples

To help you get started, we’ve selected a few timm 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 guigrpa / oao / src / utils / parallelConsoleListener.js View on Github external
processRecord(record) {
    if (
      record.fStory && record.action === 'CREATED' &&
      (record.fRoot || (record.parents.length && record.parents[0][0] === '*'))
    ) {
      this.createThread(record);
      return;
    }
    const threadId = this.getThread(record);
    if (threadId == null) return;
    if (record.action === 'CLOSED' && record.storyId === threadId) return;
    // console.log(`fStory=${record.fStory}, parents=${record.parents}, action=${record.action}`)
    const options = timmSet(this.config, 'prevTime', this.prevTime);
    const lines = this.recordToLines(record, options);
    this.prevTime = new Date(record.t);
    lines.forEach(({ text, fLongDelay }) => {
      if (fLongDelay) this.addLineToThread(threadId, '          ...');
      this.addLineToThread(threadId, text);
    });
  }
github guigrpa / oao / src / utils / removeInternalLinks.js View on Github external
if (prevDeps == null) return;
    let nextDeps = prevDeps;
    Object.keys(prevDeps).forEach(name => {
      // Is package to be removed? Only if it belongs to the internal
      // subpackage list (`pkgNames`) or it matches the custom `linkPattern`
      const fRemove =
        pkgNames.indexOf(name) >= 0 || (regex != null && regex.test(name));
      if (!fRemove) return;
      const version = prevDeps[name];
      if (version == null) return;
      nextDeps = omit(nextDeps, [name]);
      if (!removedPackagesByType[type]) removedPackagesByType[type] = {};
      removedPackagesByType[type][name] = version;
      allRemovedPackages[name] = version;
    });
    nextSpecs = timmSet(nextSpecs, type, nextDeps);
  });
github guigrpa / storyboard / packages / storyboard-extension-chrome / src / reducers / storiesReducer.js View on Github external
if (record.signalType) continue;
    if (record.fStory) {
      const [tempState, pathStr] = rxStory(state, record, options);
      state = tempState;
      if (pathStr) newStories.push(pathStr);
    } else {
      state = rxLog(state, record, options);
    }
  }

  // Don't expand stories that are already closed upon reception
  for (let j = 0, len1 = newStories.length; j < len1; j++) {
    const pathStr = newStories[j];
    const fOpen = timm.getIn(state, (`mainStory/${pathStr}/fOpen`).split('/'));
    if (fOpen) continue;
    state = timm.setIn(state, (`mainStory/${pathStr}/fExpanded`).split('/'), false);
  }
  return state;
};
github guigrpa / storyboard / packages / storyboard-extension-chrome / src / reducers / storiesReducer.js View on Github external
for (let i = 0, len = records.length; i < len; i++) {
    const record = records[i];
    if (record.signalType) continue;
    if (record.fStory) {
      const [tempState, pathStr] = rxStory(state, record, options);
      state = tempState;
      if (pathStr) newStories.push(pathStr);
    } else {
      state = rxLog(state, record, options);
    }
  }

  // Don't expand stories that are already closed upon reception
  for (let j = 0, len1 = newStories.length; j < len1; j++) {
    const pathStr = newStories[j];
    const fOpen = timm.getIn(state, (`mainStory/${pathStr}/fOpen`).split('/'));
    if (fOpen) continue;
    state = timm.setIn(state, (`mainStory/${pathStr}/fExpanded`).split('/'), false);
  }
  return state;
};
github guigrpa / concise / packages / concise / src / preprocessSchema.js View on Github external
const idField = relatedModel.fields.id;
      if (!idField) {
        throw new Error(
          `ID_FIELD_NOT_FOUND ${modelName}/${relationName}/${relatedModelName}`
        );
      }
      relation.type = idField.type;

      // Create inverse relation, if needed
      const { inverse } = relation;
      if (inverse !== false) {
        let inverseRelation =
          inverse == null || inverse === true
            ? {} // inverse shorthand
            : omit(clone(inverse), ['name']);
        inverseRelation = addDefaults(inverseRelation, {
          model: modelName,
          isPlural: true,
          isInverse: true,
          inverseName: relationName,
        });
        const idField2 = models[modelName].fields.id;
        inverseRelation.type = idField2 ? idField2.type : undefined;
        const { isPlural: isInversePlural } = inverseRelation;
        const inverseName =
          (inverse && inverse.name) ||
          (isInversePlural ? pluralize(modelName) : modelName);
        const inverseFkName = getFkName(
          inverseName,
          isInversePlural != null ? isInversePlural : true
        );
        inverseRelation.fkName = inverseFkName;
github guigrpa / jest-html / src / server / extractor.js View on Github external
) => {
  story.info('extractor', `Processing ${chalk.cyan.bold(filePath)}...`);
  const absPath = path.resolve(process.cwd(), filePath);
  const rawSnapshots = loadSnapshot(absPath);
  const suiteCss = getSuiteCss(filePath, story);
  const finalFilePath = `-/${filePath.normalize()}`;
  const prevSuite = _snapshotSuiteDict[finalFilePath];
  // $FlowFixMe
  const suite: SnapshotSuiteT = {};
  let suiteDirty = false;
  const nextIds = Object.keys(rawSnapshots);
  for (let i = 0; i < nextIds.length; i++) {
    const id = nextIds[i];
    const rawSnapshot = rawSnapshots[id];
    const [snap, html] = rawSnapshot.split(HTML_PREVIEW_SEPARATOR);
    const css = suiteCss != null ? addLast(commonCss, suiteCss) : commonCss;
    const snapshot: SnapshotT = {
      id,
      snap,
      html,
      css,
      dirty: false,
      deleted: false,
    };
    if (prevSuite && prevSuite[id]) {
      const prevSnapshot = prevSuite[id];
      const prevBaseline = prevSnapshot.baseline;
      // Copy the previous baseline, if any
      if (prevBaseline != null) {
        snapshot.baseline = prevBaseline;
        snapshot.dirty =
          html !== prevBaseline.html || snap !== prevBaseline.snap;
github guigrpa / oao / src / utils / removeInternalLinks.js View on Github external
Object.keys(prevDeps).forEach(name => {
      // Is package to be removed? Only if it belongs to the internal
      // subpackage list (`pkgNames`) or it matches the custom `linkPattern`
      const fRemove =
        pkgNames.indexOf(name) >= 0 || (regex != null && regex.test(name));
      if (!fRemove) return;
      const version = prevDeps[name];
      if (version == null) return;
      nextDeps = omit(nextDeps, [name]);
      if (!removedPackagesByType[type]) removedPackagesByType[type] = {};
      removedPackagesByType[type][name] = version;
      allRemovedPackages[name] = version;
    });
    nextSpecs = timmSet(nextSpecs, type, nextDeps);
github guigrpa / concise / packages / concise / src / mergeSchemas.js View on Github external
const mergeSchemas = (a: Schema, b: Schema): Schema => {
  let out = a;

  // Non-model specs are merged from `b`
  out = merge(out, omit(b, ['models']));

  // Merge models
  let models = out.models;
  Object.keys(b.models).forEach(modelName => {
    let model = models[modelName];
    const bModel: Object = b.models[modelName];

    // Models from b that didn't exist in a
    if (!model) {
      models = timmSet(models, modelName, bModel);
      return;
    }

    // Preexisting models
    const { description, includes, fields, relations } = bModel;
    model = merge(model, {
github guigrpa / concise / packages / concise / src / preprocessSchema.js View on Github external
}
      const idField = relatedModel.fields.id;
      if (!idField) {
        throw new Error(
          `ID_FIELD_NOT_FOUND ${modelName}/${relationName}/${relatedModelName}`
        );
      }
      relation.type = idField.type;

      // Create inverse relation, if needed
      const { inverse } = relation;
      if (inverse !== false) {
        let inverseRelation =
          inverse == null || inverse === true
            ? {} // inverse shorthand
            : omit(clone(inverse), ['name']);
        inverseRelation = addDefaults(inverseRelation, {
          model: modelName,
          isPlural: true,
          isInverse: true,
          inverseName: relationName,
        });
        const idField2 = models[modelName].fields.id;
        inverseRelation.type = idField2 ? idField2.type : undefined;
        const { isPlural: isInversePlural } = inverseRelation;
        const inverseName =
          (inverse && inverse.name) ||
          (isInversePlural ? pluralize(modelName) : modelName);
        const inverseFkName = getFkName(
          inverseName,
          isInversePlural != null ? isInversePlural : true
        );
github guigrpa / storyboard / packages / storyboard-extension-chrome / src / reducers / storiesReducer.js View on Github external
} else {
    const { parents } = record;
    if (parents != null && parents.length) {
      let parentStoryId = _.find(parents, (o) => o[0] === 'c');
      if (parentStoryId == null) parentStoryId = parents[0];
      pathStr = openStories[parentStoryId];
      if (pathStr == null && fPastRecords) pathStr = state.closedStories[parentStoryId];
    }
    if (pathStr == null) pathStr = mainStoryPathStr(fServer);
    [state, newStoryPathStr] = addStory(state, pathStr, record, options);
    state = addLog(state, newStoryPathStr, record, options).state;
    rootStoryIdx = newStoryPathStr.split('/')[1];
  }

  // Increment counter
  state = timm.updateIn(state, ['mainStory', 'records', rootStoryIdx, 'numRecords'],
    (o) => o + 1);

  // We return the new state, as well as the path of the new story (if any)
  return [state, newStoryPathStr];
};