How to use heimdalljs - 10 common examples

To help you get started, we’ve selected a few heimdalljs 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 ember-cli / ember-cli / lib / models / builder.js View on Github external
cleanup() {
    if (!this._cleanupPromise) {
      let ui = this.project.ui;
      ui.startProgress('cleaning up');
      ui.writeLine('cleaning up...');

      // ensure any addon treeFor caches are reset
      _resetTreeCache();

      this._onProcessInterrupt.removeHandler(this._cleanup);

      let node = heimdall.start({ name: 'Builder Cleanup' });

      this._cleanupPromise = promiseFinally(this.builder.cleanup(), () => {
        ui.stopProgress();
        node.stop();
      }).catch(err => {
        ui.writeLine(chalk.red('Cleanup error.'));
        ui.writeError(err);
      });
    }

    return this._cleanupPromise;
  }
github broccolijs / broccoli-funnel / index.js View on Github external
processFilters(inputPath) {
    let nextTree;

    let instrumentation = heimdall.start('derivePatches');
    let entries;

    this.outputToInputMappings = {}; // we allow users to rename files

    if (this.files && !this.exclude && !this.include) {
      entries = this._processPaths(this.files);
      // clone to be compatible with walkSync
      nextTree = FSTree.fromPaths(entries, { sortAndExpand: true });
    } else {

      if (this._matchedWalk) {
        entries = walkSync.entries(inputPath, { globs: this.include, ignore: this.exclude });
      } else {
        entries = walkSync.entries(inputPath);
      }
github ember-cli / ember-cli / lib / cli / index.js View on Github external
'use strict';

const willInterruptProcess = require('../utilities/will-interrupt-process');
const instrumentation = require('../utilities/instrumentation');
const getConfig = require('../utilities/get-config');
const ciInfo = require('ci-info');

let initInstrumentation;
if (instrumentation.instrumentationEnabled()) {
  const heimdall = require('heimdalljs');
  let initInstrumentationToken = heimdall.start('init');
  initInstrumentation = {
    token: initInstrumentationToken,
    node: heimdall.current,
  };
}

// Main entry point
const requireAsHash = require('../utilities/require-as-hash');
const packageConfig = require('../../package.json');
const logger = require('heimdalljs-logger')('ember-cli:cli/index');
const merge = require('ember-cli-lodash-subset').merge;
const path = require('path');
const heimdall = require('heimdalljs');

let version = packageConfig.version;
let name = packageConfig.name;
let trackingCode = packageConfig.trackingCode;

function loadCommands() {
github broccolijs / broccoli / lib / builder.ts View on Github external
name = node.nodeInfo.sourceDirectory;
      } else {
        name = node.nodeInfo.annotation || node.nodeInfo.name;
      }

      node.__heimdall_cookie__ = heimdall.start({
        name,
        label: node.label,
        broccoliNode: true,
        broccoliId: node.id,
        // we should do this instead of reparentNodes
        // broccoliInputIds: node.inputNodeWrappers.map(input => input.id),
        broccoliCachedNode: false,
        broccoliPluginName: node.nodeInfo.name,
      });
      node.__heimdall__ = heimdall.current;
    });
github broccolijs / broccoli / lib / builder.ts View on Github external
const seen = new Set();
  const queue = [outputNodeWrapper];
  let node;
  let parent;
  let stack: any = [];
  while ((node = queue.pop()) !== undefined) {
    if (parent === node) {
      parent = stack.pop();
    } else {
      queue.push(node);

      let heimdallNode = node.__heimdall__;
      if (heimdallNode === undefined || seen.has(heimdallNode)) {
        // make 0 time node
        const cookie = heimdall.start(Object.assign({}, heimdallNode.id));
        heimdallNode = heimdall.current;
        heimdallNode.id.broccoliCachedNode = true;
        cookie.stop();
        heimdallNode.stats.time.self = 0;
      } else {
        seen.add(heimdallNode);
        // Only push children for non "cached inputs"
        const inputNodeWrappers = node.inputNodeWrappers;
        for (let i = inputNodeWrappers.length - 1; i >= 0; i--) {
          queue.push(inputNodeWrappers[i]);
        }
      }

      if (parent) {
        heimdallNode.remove();
        parent.__heimdall__.addChild(heimdallNode);
        stack.push(parent);
github ember-cli / ember-cli / lib / models / addon.js View on Github external
cacheKeyForTree(treeType) {
    let methodsToValidate = methodsForTreeType(treeType);
    let cacheKeyStats = heimdall.statsFor('cache-key-for-tree');

    // determine if treeFor* (or other methods for tree type) overrides for the given tree
    let modifiedMethods = methodsToValidate.filter(methodName => this[methodName] !== addonProto[methodName]);

    if (modifiedMethods.length) {
      cacheKeyStats.modifiedMethods++;
      cacheKeyLogger.info(`Opting out due to: modified methods: ${modifiedMethods.join(', ')}`);
      return null; // uncacheable
    }

    // determine if treeForMethods overrides for given tree
    if (this.treeForMethods[treeType] !== DEFAULT_TREE_FOR_METHODS[treeType]) {
      cacheKeyStats.treeForMethodsOverride++;
      cacheKeyLogger.info('Opting out due to: treeForMethods override');
      return null; // uncacheable
    }
github heimdalljs / heimdalljs-logger / tests / index.js View on Github external
it('collects nodes from path to root, limited by `depth`', function() {
    heimdall.start({ name: 'a' });
    heimdall.start({ name: 'b' });
    heimdall.start({ name: 'c' });
    heimdall.start({ name: 'd' });
    heimdall.start({ name: 'e' });

    let prefixer = new Prefixer();
    prefixer.depth = 4;

    expect(prefixer.prefix()).to.match(/\[b#\d -> c#\d -> d#\d -> e#\d\] /);
  });
github heimdalljs / heimdalljs-logger / tests / index.js View on Github external
it("reads matcher and depth from heimdall's logging config if present", function() {
    let logConfig = heimdall.configFor('logging');

    logConfig.depth = 1;
    logConfig.matcher = (id) => id.name == 'hello';

    let prefixer = new Prefixer();

    heimdall.start({ name: 'hello' });
    heimdall.start({ name: 'somemthing-else' });
    heimdall.start({ name: 'hello' });

    expect(prefixer.prefix()).to.match(/\[hello#\d\] /);
  });
github heimdalljs / heimdalljs-logger / tests / index.js View on Github external
beforeEach( function() {
    heimdall._reset();
  });
github broccolijs / broccoli-funnel / index.js View on Github external
entries = this._processEntries(entries);
      nextTree = FSTree.fromEntries(entries, { sortAndExpand: true });
    }

    let patches = this._currentTree.calculatePatch(nextTree);

    this._currentTree = nextTree;

    instrumentation.stats.patches = patches.length;
    instrumentation.stats.entries = entries.length;

    let outputPath = this.outputPath;

    instrumentation.stop();

    instrumentation = heimdall.start('applyPatch', ApplyPatchesSchema);

    patches.forEach(function(entry) {
      this._applyPatch(entry, inputPath, outputPath, instrumentation.stats);
    }, this);

    instrumentation.stop();
  }

heimdalljs

Structured instrumentation library

MIT
Latest version published 6 years ago

Package Health Score

59 / 100
Full package analysis