1.0.6 • Published 11 days ago

@tugrul/async-replace v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

async-replace Build Status

Install

npm install --save @tugrul/async-replace

Sample

const {replace} = require('@tugrul/async-replace');

const text = 'the [example.com] website is the best website but [example.org] is better one';
const pattern = /\[([^\]]+)\]/g

// concurrency limiting to avoid resource saturation
const limit = 5;

async function addStatusCode(text) {

    return replace(text, pattern, async(match, [domain]) => {
        
        const {status} = await fetch('https://' + domain);

        return '[' + domain + ' (' + status + ')]';
    }, limit);

}

// the [example.com (200)] website is the best website but [example.org (200)] is better one
addStatusCode(text).then(result => console.log(result));
1.0.6

11 days ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago