How to use multi-integer-range - 5 common examples

To help you get started, we’ve selected a few multi-integer-range 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 mozilla / snakepit / src / migrate.js View on Github external
for (let type of
                Object.keys(nodeResources)
                    .map(r => nodeResources[r].type)
                    .filter(v => !v.startsWith('num:'))
                    .filter((v, i, a) => a.indexOf(v) === i) // make unique
                ) {
                let resourceIndices =
                    Object.keys(nodeResources)
                        .map(r => nodeResources[r])
                        .filter(r => r.type == type)
                        .map(r => r.index)
                if (resourceIndices.length > 0) {
                    if (!first) {
                        summary += ' + '
                    }
                    summary += type + ' ' + new MultiRange(resourceIndices.join(',')).getRanges()
                        .map(range => range[0] == range[1] ? range[0] : range[0] + '-' + range[1])
                        .join(',')
                    first = false
                }
            }
            summary += ']'
        }
        return summary
    } catch (ex) {}
}
github benwiley4000 / gif-frames / gif-frames.js View on Github external
var url = options.url;
  if (!url) {
    reject(new Error('"url" option is required.'));
    return promise;
  }
  var frames = options.frames;
  if (!frames && frames !== 0) {
    reject(new Error('"frames" option is required.'));
    return promise;
  }
  var outputType = options.outputType || 'jpg';
  var quality = options.quality;
  var cumulative = options.cumulative;

  var acceptedFrames = frames === 'all' ? 'all' : new MultiRange(frames);

  // Necessary to check if we're in Node or the browser until this is fixed:
  // https://github.com/scijs/get-pixels/issues/33
  var inputType = typeof window === 'undefined' ? 'image/gif' : '.GIF';
  getPixels(url, inputType, function (err, pixels, framesInfo) {
    if (err) {
      reject(err);
      return;
    }
    if (pixels.shape.length < 4) {
      reject(new Error('"url" input should be multi-frame GIF.'));
      return;
    }
    var frameData = [];
    var maxAccumulatedFrame = 0;
    for (var i = 0; i < pixels.shape[0]; i++) {
github micnews / story-json-to-video / bin / cli.js View on Github external
console.log('  --save-poster-images     Save first frame of each page as image');
  process.exit(1);
}

if (argv.help) {
  usage();
}

const input = argv._[0];
if (!input) {
  usage();
}

let pagesRange = null;
try {
  pagesRange = multirange(
    argv.pages || '0-',
    { parseUnbounded: true },
  );
} catch (e) {
  console.error('Invalid pages range');
  process.exit(1);
}

let json;
try {
  json = JSON.parse(fs.readFileSync(input, 'utf8'));
} catch (e) {
  console.error(`Unable to load json ${input}`);
  process.exit(1);
}
github mozilla / snakepit / src / reservations.js View on Github external
}
    let summary = ''
    for(let nodeId of Object.keys(nodes)) {
        let nodeResources = nodes[nodeId].filter(r => r.type)
        if (summary != '') {
            summary += ' + '
        }
        summary += nodeId + '['
        let first = true
        for(let type of nodeResources.map(r => r.type).filter((v, i, a) => a.indexOf(v) === i)) {
            let resourceIndices = nodeResources.filter(r => r.type == type).map(r => r.index)
            if (resourceIndices.length > 0) {
                if (!first) {
                    summary += ' + '
                }
                summary += type + ' ' + new MultiRange(resourceIndices.join(',')).getRanges()
                    .map(range => range[0] == range[1] ? range[0] : range[0] + '-' + range[1])
                    .join(',')
                first = false
            }
        }
        summary += ']'
    }
    return summary
}
github smikitky / node-multi-integer-range / example.js View on Github external
const mr = value =>
  multirange(value, { parseUnbounded: true, parseNegative: true });

multi-integer-range

Parses and manipulates multiple comma-separated integer ranges (eg 1-3,8-10)

MIT
Latest version published 2 years ago

Package Health Score

47 / 100
Full package analysis