How to use the es6-shim.Promise function in es6-shim

To help you get started, we’ve selected a few es6-shim 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 nathan-rice / radical / src / radical.ts View on Github external
execute(parameters?: IEndpointExecutionParameters) {
        var request = new XMLHttpRequest(),
            url = this.url,
            data = "",
            endpoint = this;
        return new Promise((resolve, reject) => {
            if (parameters) {
                if (parameters.arguments) {
                    url = this.url + "?" + this.toQueryString(parameters.arguments);
                }
                request.onload = function () {
                    if (this.status >= 200 && this.status < 400) {
                        if (parameters.success) parameters.success(endpoint.responseParser(this.response), this.status);
                        resolve(this.response);
                    } else {
                        if (parameters.error) parameters.error(endpoint.errorParser(this.response), this.status);
                        reject(this.response);
                    }
                };
                if (parameters.data) {
                    data = this.body.converter(parameters.data);
                }
github pokemongo-dev-contrib / pokemongo-json-pokedex / src / core / writer.ts View on Github external
public Write(): Promise {
        let promise = new Promise((resolve, reject) => {
            fs.writeFile(this.outputPath, JSON.stringify(this.parser.Parse(this.gameMaster), null, 4), err => {
                if (err) {
                    reject(err);
                }
                resolve();
            });
        });
        return promise;
    };
}

es6-shim

ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines

MIT
Latest version published 11 months ago

Package Health Score

77 / 100
Full package analysis

Popular es6-shim functions