Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const {join} = require('path');
const {readFileSync} = require('fs');
const {gzipSync} = require('zlib');
const {crunch, uncrunch} = require('../src');
const transit = require('transit-js');
const msgpack = require("msgpack-lite");
const tWriter = transit.writer('json');
const tReader = transit.reader('json');
const blobs = {
// From https://gist.githubusercontent.com/stevekrenzel/8553b5cc5462164bc9ac5b2897978405/raw/f07292666eb621a2d29dc8cee0c78a4ddb3bbadd/swapi.json
"Large SWAPI": join(__dirname, './json/large.json'),
// From https://gist.githubusercontent.com/stevekrenzel/88c16d8655d25bed7c1b61f1750eb362/raw/4c4b7806ba51afa479224011f8138ef1346f08f6/swapi.json
"Small SWAPI": join(__dirname, './json/small.json'),
// From https://catalog.data.gov/dataset/2010-census-populations-by-zip-code/resource/74f7a51d-36ae-4a28-9345-d8e07321f2e4
"Census": join(__dirname, './json/census.json'),
// From https://data.oregon.gov/api/views/i8h7-mn6v/rows.json
"Businesses": join(__dirname, './json/businesses.json'),
//"Banter Feed": join(__dirname, './json/feed.json'),
};
const composableFetch = require('../dist/index')
const { pipeP, tryCatchP } = require('../dist/index')
const transit = require('transit-js')
const log = console.log.bind(console)
const writer = transit.writer('json')
const reader = transit.reader('json')
const fetch = pipeP(
composableFetch.retryableFetch,
composableFetch.withRetry(),
composableFetch.withSafe204(),
composableFetch.withClone,
composableFetch.checkStatus,
)
const data = ({ data }) => data
const JSONReq = pipeP(
composableFetch.withBaseUrl('https://example.com/api'),
composableFetch.withHeader('Content-Type', 'application/json'),
composableFetch.withHeader('Accept', 'application/json'),
composableFetch.withJSONEncodedBody,
const { composableFetch, pipeP } = require('../dist/index')
const fetch = require('isomorphic-fetch')
const transit = require('transit-js')
const log = console.log.bind(console)
const writer = transit.writer('json')
const reader = transit.reader('json')
const decodeTransit = (res) => {
res.data = reader.read(res.data)
return res
}
const fetchTransit = pipeP(
composableFetch.withBaseUrl('https://echo-http-server.herokuapp.com'),
composableFetch.withHeader('Content-Type', 'application/json'),
composableFetch.withHeader('Accept', 'application/json'),
composableFetch.withEncodedBody((v) => writer.write(v)),
composableFetch.retryable(composableFetch.fetch1(fetch)),
composableFetch.withTimeout(1000),
composableFetch.withRetry(),
composableFetch.withSafe204(),
composableFetch.decodeTextResponse,
function makeReader(bindings) {
return transit.reader("json", {
arrayBuilder: {
init: () => List().asMutable(),
add: (ret, val) => ret.push(val),
finalize: (ret) => ret.asImmutable(),
fromArray: (arr) => List(arr)
},
mapBuilder: {
init: function() { return Map().asMutable(); },
add: function(ret, key, val) { return ret.set(key, val); },
finalize: function(ret) { return ret.asImmutable(); }
},
handlers: {
"stx": (rep) => {
let scopesets = transit.mapToObject(rep[1]);
if (List.isList(rep[0])) {
let token = rep[0];