How to use the @terascope/job-components.isString 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 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 / 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
github terascope / teraslice / packages / teraslice-client-js / src / assets.ts View on Github external
async txt(
        name = '',
        version = '',
        query: TxtSearchParams = {},
        searchOptions: SearchOptions = {}
    ): Promise {
        if (name && !isString(name)) throw new TSError('name must be of type string');
        if (version && !isString(version)) throw new TSError('version must be of type string');

        const options = Object.assign({ json: false }, searchOptions, { query });
        const pathing = path.join('/txt/assets', name, version);

        return super.get(pathing, options);
    }
}
github terascope / teraslice / packages / teraslice-client-js / src / client.ts View on Github external
function validateRequestOptions(endpoint: string, _options?: SearchOptions) {
    if (!endpoint) {
        return 'endpoint must not be empty';
    }
    if (!isString(endpoint)) {
        return 'endpoint must be a string';
    }
    return null;
}
github terascope / teraslice / packages / teraslice-client-js / src / assets.ts View on Github external
async getAsset(name: string, version = '', searchOptions: SearchOptions = {}): Promise {
        if (!name || !isString(name)) throw new TSError('name is required, and must be of type string');
        if (version && !isString(version)) throw new TSError('version if provided must be of type string');
        const pathing = path.join('/assets', name, version);
        return super.get(pathing, searchOptions);
    }