How to use the oniguruma/build/Release/onig_scanner.node.OnigString function in oniguruma

To help you get started, we’ve selected a few oniguruma 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 phenomic / phenomic / jest-setup.js View on Github external
jest.doMock("oniguruma", function mockOniguruma() {
  // https://github.com/atom/node-oniguruma/blob/3664b41e615697a3abd3b13e67226d177fa4143b/src/oniguruma.js
  // with just "configurable: true" on Object.defineProperty

  "use strict";

  const OnigScanner = require("oniguruma/build/Release/onig_scanner.node")
    .OnigScanner;
  const OnigString = require("oniguruma/build/Release/onig_scanner.node")
    .OnigString;

  function OnigRegExp(source) {
    this.source = source;
    this.scanner = new OnigScanner([this.source]);
  }

  OnigRegExp.prototype.captureIndicesForMatch = function(string, match) {
    var capture, captureIndices, i, len;
    if (match != null) {
      captureIndices = match.captureIndices;
      string = this.scanner.convertToString(string);
      for (i = 0, len = captureIndices.length; i < len; i++) {
        capture = captureIndices[i];
        capture.match = string.slice(capture.start, capture.end);
      }