Skip to content

Use of async makes things difficult. Use promises instead. #71

Open
@bendavis78

Description

@bendavis78

I'm trying to use this in conjunction with printedjs, but it doesn't work because this library manipulates dom in a setTimeout(). Is there a good reason this needs to be wrapped in a setTimeout? If so, why not use promises? That would give us more control over the situation.

Activity

T3sT3ro

T3sT3ro commented on Dec 4, 2022

@T3sT3ro

I modified the code and replaced current implementation with the following in my script:

function lineNumbersBlock (element, options) {
    if (typeof element !== 'object') return;

    return new Promise((resolve, reject) => {
        element.innerHTML = lineNumbersInternal(element, options);
        resolve();
    })
}

and it forks for me ¯\_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Use of async makes things difficult. Use promises instead. · Issue #71 · wcoder/highlightjs-line-numbers.js