How to use @cubbit/web-file-stream - 1 common examples

To help you get started, we’ve selected a few @cubbit/web-file-stream 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 cubbit / enigma / src / web / modules / Hash.ts View on Github external
{
            if(typeof file === 'string')
                return reject('Path not supported. First argument must be a File');

            // @ts-ignore
            const algorithm: Hash.Algorithm = (options && options.algorithm) || Hash.Algorithm[defaults.hash.algorithm as any] as Hash.Algorithm;
            // @ts-ignore
            const encoding = (options && options.encoding) || Hash.Encoding[defaults.hash.encoding as any] as Hash.Encoding;

            if(algorithm !== Hash.Algorithm.SHA256)
                return reject(new Error('Unsupported algorithm'));

            const stream = new HashStream();
            stream.on('error', reject);
            stream.on('finish', () => resolve(stream.read().toString(encoding)));
            WebFileStream.create_read_stream(file).pipe(stream);
        });
    }

@cubbit/web-file-stream

Node's file stream APIs for the web

MIT
Latest version published 4 years ago

Package Health Score

52 / 100
Full package analysis

Popular @cubbit/web-file-stream functions