How to use the string-replace-async.seq function in string-replace-async

To help you get started, we’ve selected a few string-replace-async 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 embark-framework / embark / src / lib / modules / specialconfigs / index.js View on Github external
replaceWithENSAddress(cmd, cb) {
    const self = this;
    let regex = /\'[a-zA-Z0-9.]+\.eth\'/g;
    return stringReplaceAsync.seq(cmd, regex, (ensDomain) => {
      ensDomain = ensDomain.slice(1, ensDomain.length - 1);
      return (new Promise((resolve, reject) => {
        self.events.request("ens:resolve", ensDomain, (err, address) => {
          if(err) {
            return reject(new Error(err));
          }
          address = `'${address}'`;
          return resolve(address);
        });
      }));
    }).then((address) => {
      cb(null, address);
    }).catch(cb);
  }
github analog-nico / pxl-for-emails / lib / PxlForEmails.js View on Github external
return BPromise.try(() => {

            let fullMetadata = getMetadataForOpenTracking(metadata)

            return stringReplaceAsync.seq(
                htmlEmail,
                this.options.openTracking.regexLinks,
                BPromise.coroutine(function *(match, p1, link, p3) {

                    if (this.options.openTracking.applyToFirstCandidateOnly && numCandidate > 0) {
                        return match
                    }

                    let applyInstruction = this.options.openTracking.shouldApply(link)
                    if (!applyInstruction) {
                        return match
                    }

                    if (!openPxl) {

                        if (applyInstruction.metadata) {
github embark-framework / embark / packages / plugins / embark-specialconfigs / src / listConfigs.js View on Github external
const replaceWithAddresses = (cmd) => {
      let regex = /\$\w+\[?\d?\]?/g;
      return stringReplaceAsync.seq(cmd, regex, (match, index) => {
        return (new Promise((resolve, reject) => {
          if (match.startsWith('$accounts')) {
            let accountIndex = cmd.substring(index + 10, index + 12);
            accountIndex = parseInt(accountIndex, 10);
            return this.events.request('blockchain:getAccounts', (err, accounts) => {
              if (err) {
                return reject('Error getting accounts: ' + err.message || err);
              }
              if (!accounts[accountIndex]) {
                return reject(__('No corresponding account at index %d', accountIndex));
              }
              resolve(accounts[accountIndex]);
            });
          }

          let referedContractName = match.slice(1);
github embark-framework / embark / packages / plugins / specialconfigs / src / listConfigs.js View on Github external
const replaceWithAddresses = (cmd) => {
      let regex = /\$\w+\[?\d?\]?/g;
      return stringReplaceAsync.seq(cmd, regex, (match, index) => {
        return (new Promise((resolve, reject) => {
          if (match.startsWith('$accounts')) {
            let accountIndex = cmd.substring(index + 10, index + 12);
            accountIndex = parseInt(accountIndex, 10);
            return this.events.request('blockchain:getAccounts', (err, accounts) => {
              if (err) {
                return reject('Error getting accounts: ' + err.message || err);
              }
              if (!accounts[accountIndex]) {
                return reject(__('No corresponding account at index %d', accountIndex));
              }
              resolve(accounts[accountIndex]);
            });
          }

          let referedContractName = match.slice(1);
github embark-framework / embark / packages / plugins / embark-specialconfigs / src / listConfigs.js View on Github external
const replaceWithENSAddress = (cmd) => {
      let regex = /\'[a-zA-Z0-9.]+\.eth\'/g;
      return stringReplaceAsync.seq(cmd, regex, (ensDomain) => {
        ensDomain = ensDomain.slice(1, ensDomain.length - 1);
        return (new Promise((resolve, reject) => {
          this.events.request("ens:resolve", ensDomain, (err, address) => {
            if(err) {
              return reject(new Error(err));
            }
            address = `'${address}'`;
            return resolve(address);
          });
        }));
      });
    };
github embark-framework / embark / packages / plugins / specialconfigs / src / listConfigs.js View on Github external
const replaceWithENSAddress = (cmd) => {
      let regex = /\'[a-zA-Z0-9.]+\.eth\'/g;
      return stringReplaceAsync.seq(cmd, regex, (ensDomain) => {
        ensDomain = ensDomain.slice(1, ensDomain.length - 1);
        return (new Promise((resolve, reject) => {
          this.events.request("namesystem:resolve", ensDomain, (err, address) => {
            if (err) {
              return reject(new Error(err));
            }
            address = `'${address}'`;
            return resolve(address);
          });
        }));
      });
    };
github analog-nico / pxl-for-emails / lib / PxlForEmails.js View on Github external
return BPromise.try(() => {

            let fullMetadata = getMetadataForClickTracking(metadata, referToOpenTrackingPxl, openTrackingPxl)

            return stringReplaceAsync.seq(
                htmlEmail,
                this.options.clickTracking.regexLinks,
                BPromise.coroutine(function *(match, p1, link, p3) {

                    let applyInstruction = this.options.clickTracking.shouldApply(link)
                    if (!applyInstruction) {
                        return match
                    }

                    if (referToOpenTrackingPxl && !openTrackingPxl) {

                        let createdOpenPxl = yield this.options.pxl.createPxl(getMetadataForOpenTracking(metadata))
                        openTrackingPxl = createdOpenPxl.pxl

                        fullMetadata = getMetadataForClickTracking(metadata, referToOpenTrackingPxl, openTrackingPxl)

string-replace-async

Asynchronous String.prototype.replace()

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis

Popular string-replace-async functions