All Projects → ironSource → aws-api-read-stream

ironSource / aws-api-read-stream

Licence: other
Turn an AWS api call into a readable stream

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to aws-api-read-stream

tutorial
Tutorials to help you build your first Swim app
Stars: ✭ 27 (+12.5%)
Mutual labels:  stream-api
front-matter-manipulator
A utility for parsing and manipulating documents with Front Matter
Stars: ✭ 25 (+4.17%)
Mutual labels:  npm-package
useCustomHooks
📦 npm package containing a set of custom hooks for your next React project.
Stars: ✭ 12 (-50%)
Mutual labels:  npm-package
npmlint
[DEPRECATED] Lint your npm package
Stars: ✭ 57 (+137.5%)
Mutual labels:  npm-package
react-microsoft-login
Microsoft services authorization with React.
Stars: ✭ 65 (+170.83%)
Mutual labels:  npm-package
titanium-vue
Use Vue.js to easily create native mobile apps with Axway Appcelerator Titanium.
Stars: ✭ 45 (+87.5%)
Mutual labels:  npm-package
eslint-plugin-vue-scoped-css
ESLint plugin for Scoped CSS in Vue.js
Stars: ✭ 58 (+141.67%)
Mutual labels:  npm-package
jsdoc-api
A programmatic interface for jsdoc3 with a few extra features
Stars: ✭ 55 (+129.17%)
Mutual labels:  npm-package
youtube-playlist
❄️ Extract links, ids, and names from a youtube playlist
Stars: ✭ 73 (+204.17%)
Mutual labels:  npm-package
angular2-yandex-maps
Angular 2 components Yandex Maps.
Stars: ✭ 26 (+8.33%)
Mutual labels:  npm-package
djb2a
DJB2a non-cryptographic hash function
Stars: ✭ 31 (+29.17%)
Mutual labels:  npm-package
fadable
Fade in elements as they move into view, at both the bottom and top of the viewport.
Stars: ✭ 16 (-33.33%)
Mutual labels:  npm-package
rescheme
JSON Rescheme project will help you change the JSON structure easily using declarative syntax
Stars: ✭ 16 (-33.33%)
Mutual labels:  npm-package
hydra-js
DOES NOT WORK WITH VERSIONS > 0.10.0 - A simple library to help you build node-based identity providers that work with Hydra.
Stars: ✭ 17 (-29.17%)
Mutual labels:  npm-package
validid
A Javascript library to validate ID card numbers of China, Taiwan, Hong Kong and South Korea
Stars: ✭ 37 (+54.17%)
Mutual labels:  npm-package
js-mdict
*.mdx/*.mdd interpreter js implements
Stars: ✭ 91 (+279.17%)
Mutual labels:  npm-package
sdk-js
Viblo Javascript SDK
Stars: ✭ 17 (-29.17%)
Mutual labels:  npm-package
react-folder-tree
A versatile react treeview library that supports custom icons and event handlers
Stars: ✭ 56 (+133.33%)
Mutual labels:  npm-package
v-svg-icons
Svg icons for VueJS.
Stars: ✭ 36 (+50%)
Mutual labels:  npm-package
ts-ci
🚀 A starter for TS projects meant to be published on NPM.
Stars: ✭ 282 (+1075%)
Mutual labels:  npm-package

aws-api-read-stream

Turn an aws api call into a readable stream.

Install

npm i aws-api-read-stream

example

Piping the result of s3.listObjectsV2()

Take care to use NextToken or ContinuationToken accordingly.

const aws = require('aws-sdk')
const APIStream = require('aws-api-read-stream')
const { promisify } = require('util')
const pipeline = promisify(require('stream').pipeline)

async function main() {
    const s3 = new aws.S3()

    const s = APIStream.from((nextToken) => {
        return s3.listObjectsV2({
            Bucket: 'your-bucket-here',
            ContinuationToken: nextToken
        }).promise()
    })

    // convert the object stream to strings using async generator
    // (node 13.* and above)
    const transform = async function*(source) {
        for await (const chunk of source) {
            yield JSON.stringify(chunk)
        }
    }

    await pipeline(s, transform, process.stdout)
}

main()

Keep reading until the stream finishes. This will buffer the results in an internal array, be wary though, because this might crash the process if it runs out of memory

const aws = require('aws-sdk')
const APIStream = require('aws-api-read-stream')
const { promisify } = require('util')
const pipeline = promisify(require('stream').pipeline)

async function main() {
    const s3 = new aws.S3()

    const s = APIStream.from((nextToken) => {
        return s3.listObjectsV2({
            Bucket: 'your-bucket-here',
            ContinuationToken: nextToken
        }).promise()
    })

    const results = await s.readAll()
}

main()

Provide Readable stream options during initialization. objectMode will always be set to true

const s = APIStream.from((nextToken) => {
    return s3.listObjectsV2({
        Bucket: 'your-bucket-here',
        ContinuationToken: nextToken
    }).promise()
}, { options: { ... your options here } })

Start with an existing nextToken

const s = APIStream.from((nextToken) => {
    return s3.listObjectsV2({
        Bucket: 'your-bucket-here',
        ContinuationToken: nextToken
    }).promise()
}, { nextToken: '123123' })
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].