How to use the @0x/utils.promisify function in @0x/utils

To help you get started, we’ve selected a few @0x/utils 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 0xProject / 0x-monorepo / packages / sol-compiler / src / utils / fs_wrapper.ts View on Github external
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';

export const fsWrapper = {
    readdirAsync: promisify(fs.readdir),
    readFileAsync: promisify(fs.readFile),
    writeFileAsync: promisify(fs.writeFile),
    mkdirpAsync: promisify(mkdirp),
    doesPathExistSync: fs.existsSync,
    rmdirSync: fs.rmdirSync,
    removeFileAsync: promisify(fs.unlink),
    statAsync: promisify(fs.stat),
    appendFileAsync: promisify(fs.appendFile),
    accessAsync: promisify(fs.access),
    doesFileExistAsync: async (filePath: string): Promise => {
        try {
            await fsWrapper.accessAsync(
                filePath,
                // node says we need to use bitwise, but tslint says no:
                fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
            );
        } catch (err) {
github 0xProject / 0x-monorepo / packages / sol-compiler / src / utils / fs_wrapper.ts View on Github external
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';

export const fsWrapper = {
    readdirAsync: promisify(fs.readdir),
    readFileAsync: promisify(fs.readFile),
    writeFileAsync: promisify(fs.writeFile),
    mkdirpAsync: promisify(mkdirp),
    doesPathExistSync: fs.existsSync,
    rmdirSync: fs.rmdirSync,
    removeFileAsync: promisify(fs.unlink),
    statAsync: promisify(fs.stat),
    appendFileAsync: promisify(fs.appendFile),
    accessAsync: promisify(fs.access),
    doesFileExistAsync: async (filePath: string): Promise => {
        try {
            await fsWrapper.accessAsync(
                filePath,
                // node says we need to use bitwise, but tslint says no:
                fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
            );
        } catch (err) {
            return false;
github 0xProject / 0x-monorepo / packages / sol-compiler / src / utils / fs_wrapper.ts View on Github external
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';

export const fsWrapper = {
    readdirAsync: promisify(fs.readdir),
    readFileAsync: promisify(fs.readFile),
    writeFileAsync: promisify(fs.writeFile),
    mkdirpAsync: promisify(mkdirp),
    doesPathExistSync: fs.existsSync,
    rmdirSync: fs.rmdirSync,
    removeFileAsync: promisify(fs.unlink),
    statAsync: promisify(fs.stat),
    appendFileAsync: promisify(fs.appendFile),
    accessAsync: promisify(fs.access),
    doesFileExistAsync: async (filePath: string): Promise => {
        try {
            await fsWrapper.accessAsync(
                filePath,
                // node says we need to use bitwise, but tslint says no:
                fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
            );
        } catch (err) {
            return false;
        }
github 0xProject / 0x-monorepo / packages / sol-compiler / src / utils / fs_wrapper.ts View on Github external
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';

export const fsWrapper = {
    readdirAsync: promisify(fs.readdir),
    readFileAsync: promisify(fs.readFile),
    writeFileAsync: promisify(fs.writeFile),
    mkdirpAsync: promisify(mkdirp),
    doesPathExistSync: fs.existsSync,
    rmdirSync: fs.rmdirSync,
    removeFileAsync: promisify(fs.unlink),
    statAsync: promisify(fs.stat),
    appendFileAsync: promisify(fs.appendFile),
    accessAsync: promisify(fs.access),
    doesFileExistAsync: async (filePath: string): Promise => {
        try {
            await fsWrapper.accessAsync(
                filePath,
                // node says we need to use bitwise, but tslint says no:
                fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
            );
        } catch (err) {
            return false;
        }
        return true;
    },
};
github 0xProject / 0x-monorepo / packages / sol-compiler / src / utils / fs_wrapper.ts View on Github external
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';

export const fsWrapper = {
    readdirAsync: promisify(fs.readdir),
    readFileAsync: promisify(fs.readFile),
    writeFileAsync: promisify(fs.writeFile),
    mkdirpAsync: promisify(mkdirp),
    doesPathExistSync: fs.existsSync,
    rmdirSync: fs.rmdirSync,
    removeFileAsync: promisify(fs.unlink),
    statAsync: promisify(fs.stat),
    appendFileAsync: promisify(fs.appendFile),
    accessAsync: promisify(fs.access),
    doesFileExistAsync: async (filePath: string): Promise => {
        try {
            await fsWrapper.accessAsync(
                filePath,
                // node says we need to use bitwise, but tslint says no:
                fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
            );
        } catch (err) {
            return false;
        }
        return true;
    },
};
github 0xProject / 0x-monorepo / packages / sol-compiler / src / utils / fs_wrapper.ts View on Github external
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';

export const fsWrapper = {
    readdirAsync: promisify(fs.readdir),
    readFileAsync: promisify(fs.readFile),
    writeFileAsync: promisify(fs.writeFile),
    mkdirpAsync: promisify(mkdirp),
    doesPathExistSync: fs.existsSync,
    rmdirSync: fs.rmdirSync,
    removeFileAsync: promisify(fs.unlink),
    statAsync: promisify(fs.stat),
    appendFileAsync: promisify(fs.appendFile),
    accessAsync: promisify(fs.access),
    doesFileExistAsync: async (filePath: string): Promise => {
        try {
            await fsWrapper.accessAsync(
                filePath,
                // node says we need to use bitwise, but tslint says no:
                fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
            );
        } catch (err) {
            return false;
        }
        return true;
    },
};
github 0xProject / 0x-monorepo / packages / sol-compiler / src / utils / fs_wrapper.ts View on Github external
import { promisify } from '@0x/utils';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';

export const fsWrapper = {
    readdirAsync: promisify(fs.readdir),
    readFileAsync: promisify(fs.readFile),
    writeFileAsync: promisify(fs.writeFile),
    mkdirpAsync: promisify(mkdirp),
    doesPathExistSync: fs.existsSync,
    rmdirSync: fs.rmdirSync,
    removeFileAsync: promisify(fs.unlink),
    statAsync: promisify(fs.stat),
    appendFileAsync: promisify(fs.appendFile),
    accessAsync: promisify(fs.access),
    doesFileExistAsync: async (filePath: string): Promise => {
        try {
            await fsWrapper.accessAsync(
                filePath,
                // node says we need to use bitwise, but tslint says no:
                fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
            );
        } catch (err) {
            return false;
        }
        return true;
    },
};
github 0xProject / 0x-monorepo / packages / web3-wrapper / src / web3_wrapper.ts View on Github external
public async sendRawPayloadAsync<a>(payload: Partial): Promise</a><a> {
        const sendAsync = this._provider.sendAsync.bind(this._provider);
        const payloadWithDefaults = {
            id: this._jsonRpcRequestId++,
            params: [],
            jsonrpc: '2.0',
            ...payload,
        };
        const response = await promisify(sendAsync)(payloadWithDefaults);
        if (response.error) {
            throw new Error(response.error.message);
        }
        const result = response.result;
        return result;
    }
    /**</a>
github 0xProject / 0x-monorepo / packages / sol-tracing-utils / src / trace_collector.ts View on Github external
import { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter';
import { constants } from './constants';
import { parseSourceMap } from './source_maps';
import {
    ContractData,
    Coverage,
    SourceRange,
    Subtrace,
    TraceInfo,
    TraceInfoExistingContract,
    TraceInfoNewContract,
} from './types';
import { utils } from './utils';

const mkdirpAsync = promisify(mkdirp);

export type SingleFileSubtraceHandler = (
    contractData: ContractData,
    subtrace: Subtrace,
    pcToSourceRange: { [programCounter: number]: SourceRange },
    fileIndex: number,
) =&gt; Coverage;

/**
 * TraceCollector is used by CoverageSubprovider to compute code coverage based on collected trace data.
 */
export class TraceCollector {
    private readonly _artifactAdapter: AbstractArtifactAdapter;
    private readonly _logger: Logger;
    private _contractsData!: ContractData[];
    private readonly _collector = new Collector();