Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function checkDemoAPI(toSend, backupUrl = null, backupPayload = null) {
const hsh = hash.sha1(toSend);
console.log("CHECKING DEMOAPI: " + hsh);
if (DemoAPI.hasOwnProperty(hsh)) {
// Relies on a symbolic link being present in the dist folder to the demo folder
const path = './demo/' + DemoAPI[hsh]
console.log("TRYING TO SENDING STATIC: ", path);
const follow = (response) => responseJson(response, backupUrl, backupPayload)
return fetch(path).then(follow)
}
return d3.json(backupUrl, backupPayload)
}
request(service, method, params, options) {
const that = this;
const credentials = Object.assign({}, that.getCredentials());
// Make sure options is an object (honors wrong calls of request)
const requestOptions = _.isObject(options) ? options : {};
const shouldCache = _.get(requestOptions, 'useCache', false);
const paramsWithRegion = _.merge({}, params, {
region: _.get(options, 'region'),
});
const paramsHash = objectHash.sha1(paramsWithRegion);
const MAX_TRIES = 4;
const persistentRequest = f =>
new BbPromise((resolve, reject) => {
const doCall = numTry => {
f()
// We're resembling if/else logic, therefore single `then` instead of `then`/`catch` pair
.then(resolve, e => {
if (
numTry < MAX_TRIES &&
e.statusCode !== 403 && // Invalid credentials
((e.providerError && e.providerError.retryable) || e.statusCode === 429)
) {
that.serverless.cli.log(
_.join(
[
`Recoverable error occurred (${e.message}), sleeping for 5 seconds.`,
useFactory: async (
connections: Map,
mongoModuleOptions: MongoModuleOptions,
) => {
const { uri, clientOptions } = mongoModuleOptions;
const key = hash.sha1({
uri,
clientOptions,
});
if (connections.has(key)) {
return connections.get(key);
}
const client = new MongoClient(
uri,
clientOptions || DEFAULT_MONGO_CLIENT_OPTIONS,
);
connections.set(key, client);
return await client.connect();
},
inject: [getContainerToken(mongoContainerName), MONGO_MODULE_OPTIONS],
parseYaml: function (req, config, mainCb, provider, yaml, cb) {
try {
var jsonYaml = yamljs.parse(yaml);
var sha = hash.sha1(jsonYaml);
}
catch (e) {
req.soajs.log.error(e);
return mainCb({"code": 984, "msg": config.errors[984]});
}
if (typeof jsonYaml !== "object") {
return mainCb({"code": 984, "msg": config.errors[984]});
}
switch (provider) {
case 'travis':
if (!(jsonYaml && jsonYaml.after_success)) {
jsonYaml.after_success = [];
}
if (jsonYaml && jsonYaml.after_success && jsonYaml.after_success.indexOf("node ./soajs.cd.js") === -1) {
jsonYaml.after_success.push("node ./soajs.cd.js");
calcClusters(region: Region) {
const MIN_DISTANCE = convertPtInDistance(region, this.props.minDistance || 30, this.mapHeight);
this.MIN_DISTANCE_SQR = MIN_DISTANCE * MIN_DISTANCE;
const clusters = this.calc(new Array(this.getChildren().length).fill(1)
.map((i, index) => [index]));
const clusterInfo = [];
for (let i = 0; i < clusters.length; ++i) {
const clusterCenter = calcCenter(clusters[i].map(k => this.getChildren()[k].props.coordinate));
clusterInfo.push({
center: clusterCenter,
points: clusters[i],
hash: hash.sha1(clusters[i]),
});
}
return clusterInfo;
}
distinctUntilChanged((x, y) => (x && sha1(x)) === (y && sha1(y)))
)
function name(strain) {
if (strain) {
return hash.sha1(strain).substr(24);
}
return null;
}
createElement(renderer: Renderer2, injectable: DOMInjectable): T | undefined {
if (!injectable || !injectable.element) return undefined
const elm = renderer.createElement(injectable.element) as T
const id = sha1(JSON.stringify(injectable))
renderer.setProperty(elm, 'id', id)
if (injectable.value) renderer.setValue(elm, injectable.value)
Object.keys(injectable.attributes || {})
.forEach(key => renderer.setAttribute(elm, key, (injectable.attributes || {})[key] as any))
return elm
}