How to use the multistream.obj function in multistream

To help you get started, we’ve selected a few multistream 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 Fitbit / fitbit-sdk-toolchain / src / index.ts View on Github external
buildId: string;
  onDiagnostic?: DiagnosticHandler;
}) {
  const deviceJSPipeline: Stream[] = [
    // TODO: remove is-defined assertion ('!')
    buildComponent({
      projectConfig,
      onDiagnostic,
      component: ComponentType.DEVICE,
    })!,
  ];

  const processedJS = new playbackStream({ objectMode: true });
  deviceJSPipeline.push(processedJS);

  return multistream.obj([
    // Sequence the build process: wait until compilation finishes
    // before building the resources for each component.
    new pumpify.obj(
      ...deviceJSPipeline,
      // We don't want to send the JS file downstream directly. It will
      // be played back into the individual device component pipelines.
      dropStream.obj(),
    ),
    ...projectConfig.buildTargets.map((family) =>
      lazyObjectReadable(() => {
        const { platform, displayName, maxDeviceBundleSize } = buildTargets[
          family
        ];
        onDiagnostic({
          messageText: `Building app for ${displayName}`,
          category: DiagnosticCategory.Message,
github kartotherian / kartotherian / packages / cassandra / CassandraStore.js View on Github external
}
        // options.zoom===0 is a temp workaround because the info data used to be stored in the zoom=0,idx=1
        if (end < blockEnd || options.zoom === 0) {
            conds += ' AND idx < ?';
            params.push(end);
        }
        let query = 'SELECT ' + fields + ' FROM ' + self.table + ' WHERE ' + conds;
        return self.client.stream(query, params, {prepare: true, autoPage: true});
    };

    let ms;
    if (self.blocksize) {
        let blockIdx = Math.floor(start / self.blocksize),
            toBlockIdx = Math.floor((end - 1) / self.blocksize);

        ms = multistream.obj(cb => {
            if (blockIdx > toBlockIdx) {
                cb();
            } else {
                try {
                    let bi = blockIdx++;
                    cb(null, createStream(bi * self.blocksize, Math.min(maxEnd, (bi + 1) * self.blocksize)));
                } catch (err) {
                    cb(err);
                }
            }
        });
    } else {
        ms = createStream(0, maxEnd);
    }

    return promistreamus(ms, value => {
github beautifulinteractions / node-quadstore / lib / getstream / index.js View on Github external
const executeStrategy = (strategy, opts, store) => {
  const streamFactories = strategy.paths.map(
    (path) => generateStreamFactoryForPath(store, strategy, path),
  );
  let multiStream = multistream.obj(streamFactories);
  if (opts.offset || opts.limit) {
    let multiIterator = AsyncIterator.wrap(multiStream);
    if (opts.offset) {
      multiIterator = multiIterator.skip(opts.offset);
    }
    if (opts.limit) {
      multiIterator = multiIterator.take(opts.limit);
    }
    multiStream = utils.createIteratorStream(multiIterator);
  }
  return multiStream;
};
github Fitbit / fitbit-sdk-toolchain / src / index.ts View on Github external
() =>
      new pumpify.obj(
        multistream.obj(components),
        makeCompanionManifest({
          projectConfig,
          buildId,
          hasSettings: !!settings,
        }),
        zip('companion.zip'),
        gulpSetProperty({
          componentBundle: { type: 'companion' },
        }),
        sourceMaps.emitter,
      ),
  );
github s3ththompson / readrc / index.js View on Github external
Readrc.prototype.feeds = function () {
  return multistream.obj(this._feeds)
}
github Frando / multihyperdb / index.js View on Github external
var streams = Object.keys(this.dbs).map(function (key) {
    return function () {
      var transform = new Transform({objectMode: true})
      transform._transform = function (nodes, enc, next) {
        function transform (node) {
          return {node: node, dbKey: key}
        }
        if (Array.isArray(nodes)) this.push(nodes.map(transform))
        else this.push(transform(nodes))
        next()
      }
      return self.dbs[key].db.createReadStream(prefix).pipe(transform)
    }
  })

  return multistream.obj(streams)
}
github kartotherian / kartotherian / packages / tilerator / lib / cassandra.js View on Github external
conds += ' AND idx >= ?';
            params.push(start);
        }
        if (end < blockEnd) {
            conds += ' AND idx < ?';
            params.push(end);
        }
        var query = 'SELECT ' + fields + ' FROM ' + self.table + ' WHERE ' + conds;
        return self.client.stream(query, params, {prepare: true, autoPage: true});
    };

    var ms;
    if (self.blocksize) {
        var blockIdx = Math.floor(start / self.blocksize);
        var toBlockIdx = Math.floor((end - 1) / self.blocksize);
        ms = multistream.obj(function() {
            if (blockIdx > toBlockIdx) return false;
            var s = createStream(blockIdx * self.blocksize,
                Math.min(maxEnd, (blockIdx + 1) * self.blocksize));
            blockIdx++;
            return s;
        });
    } else {
        ms = createStream(0, maxEnd);
    }

    return promistreamus(ms, function(value) {
        if ((dateBefore !== false && value.wt >= dateBefore) ||
            (dateFrom !== false && value.wt < dateFrom) ||
            (options.smallerThan && value.tile.length >= options.smallerThan) ||
            (options.biggerThan && value.tile.length < options.biggerThan)
        ) {
github Fitbit / fitbit-sdk-toolchain / src / index.ts View on Github external
onDiagnostic: addDiagnosticTarget(DiagnosticTarget.App, onDiagnostic),
        }),
      ),
    );
  }

  const companion = buildCompanion({
    projectConfig,
    buildId,
    onDiagnostic: addDiagnosticTarget(DiagnosticTarget.Companion, onDiagnostic),
  });

  if (companion) components.push(companion);

  return new pumpify.obj(
    multistream.obj(components),
    appPackageManifest({
      projectConfig,
      buildId,
    }),
    zip('app.fba'),
  );
}

multistream

A stream that emits multiple other streams one after another (streams3)

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis