aws-collection-stream
Advanced tools
Comparing version 0.0.2 to 0.0.3
38
index.js
@@ -16,11 +16,21 @@ const H = require ( 'highland' ); | ||
} ) | ||
.errors ( ( error, push ) => error.code === 'ThrottlingException' ? push ( null, 'ThrottlingException' ) : push ( error ) ) | ||
.flatMap ( e => { | ||
if ( R.type ( e ) === 'String' && e === 'ThrottlingException' ) { | ||
return H ( ( push, next ) => setTimeout ( () => next ( | ||
H.wrapCallback ( R.bind ( serviceObject[serviceMethod], serviceObject ) )( { ...parms, [nextTokenKeyName]: nextToken } ) | ||
), 1000 ) ); | ||
} | ||
return H ( [ e ] ); | ||
} ) | ||
.flatMap ( ( { [collectionName]: collection, [nextTokenKeyName]: nextToken } ) => nextToken ? H ( collection ) | ||
.concat ( awsCollectionStream ( { | ||
serviceObject, | ||
serviceMethod, | ||
collectionName, | ||
parms, | ||
nextTokenKeyName, | ||
nextToken | ||
} ) ) : H ( collection ) | ||
.concat ( awsCollectionStream ( { | ||
serviceObject, | ||
serviceMethod, | ||
collectionName, | ||
parms, | ||
nextTokenKeyName, | ||
nextToken | ||
} ) ) : H ( collection ) | ||
); | ||
@@ -47,5 +57,15 @@ | ||
return H.wrapCallback ( R.bind ( serviceObject[serviceMethod], serviceObject ) )( parms ) | ||
.errors ( ( error, push ) => error.code === 'ThrottlingException' ? push ( null, 'ThrottlingException' ) : push ( error ) ) | ||
.flatMap ( e => { | ||
if ( R.type ( e ) === 'String' && e === 'ThrottlingException' ) { | ||
return H ( ( push, next ) => setTimeout ( () => next ( | ||
H.wrapCallback ( R.bind ( serviceObject[serviceMethod], serviceObject ) )( parms ) | ||
), 1000 ) ); | ||
} | ||
return H ( [ e ] ); | ||
} ) | ||
.flatMap ( result => { | ||
const collectionName = R.find ( key => R.type ( result[key] ) === 'Array', R.keys ( result ) ); | ||
const nextTokenKeyName = R.find ( key => key.toLowerCase () === 'nexttoken', R.keys ( result ) ); | ||
const nextTokenKeyName = R.find ( key => key.toLowerCase () === 'nexttoken' || key === 'Marker', R.keys ( result ) ); | ||
@@ -52,0 +72,0 @@ if ( nextTokenKeyName ) { |
{ | ||
"name": "aws-collection-stream", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Takes care of any paginated AWS SDK call, and return the output as a highland.js stream of objects.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4784
80