How to use the @terascope/job-components.isPlainObject function in @terascope/job-components

To help you get started, we’ve selected a few @terascope/job-components 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 terascope / teraslice / packages / teraslice-client-js / src / client.ts View on Github external
function getRequestOptionsWithData(data: any, options: SearchOptions) {
    if (isPlainObject(data) || Array.isArray(data)) {
        return Object.assign({}, options, { body: data });
    }
    return Object.assign({}, options, { body: data, json: false });
}
github terascope / teraslice / packages / teraslice-client-js / src / client.ts View on Github external
function getErrorFromResponse(response: any) {
    let { body } = response;

    if (body && isString(body)) {
        try {
            body = JSON.parse(body);
        } catch (err) {
            return { message: body };
        }
    }

    if (body && isPlainObject(body)) {
        if (isString(body.error)) {
            return {
                message: body.error
            };
        }
        return {
            message: body.message,
            code: body.error
        };
    }
    return {};
}
github terascope / teraslice / packages / teraslice-client-js / src / executions.ts View on Github external
async errors(exId?: string | SearchQuery, opts?: SearchQuery): Promise {
        const options: SearchQuery = {};
        if (isString(exId)) {
            if (isPlainObject(opts)) {
                options.query = opts;
            }

            return this.get(`/ex/${exId}/errors`, options as SearchOptions);
        }

        if (isPlainObject(exId)) {
            options.query = exId;
        }

        return this.get('/ex/errors', options as SearchOptions);
    }