Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
defs: D2ManifestDefinitions,
buckets: InventoryBuckets,
characterId: string,
profileInfo: DestinyProfileResponse,
mergedCollectibles: {
[hash: number]: DestinyCollectibleComponent;
},
previousItems: Set,
newItems: Set,
itemInfoService: ItemInfoSource,
lastPlayedDate: Date
): D2Store {
const character = profileInfo.characters.data![characterId];
const characterInventory =
idx(profileInfo.characterInventories.data, (data) => data[characterId].items) || [];
const profileInventory = idx(profileInfo.profileInventory.data, (data) => data.items) || [];
const characterEquipment =
idx(profileInfo.characterEquipment.data, (data) => data[characterId].items) || [];
const itemComponents = profileInfo.itemComponents;
const progressions =
idx(profileInfo.characterProgressions.data, (data) => data[characterId].progressions) || [];
const uninstancedItemObjectives =
idx(
profileInfo.characterProgressions.data,
(data) => data[characterId].uninstancedItemObjectives
) || [];
const store = makeCharacter(defs, character, lastPlayedDate);
// This is pretty much just needed for the xp bar under the character header
store.progression = progressions ? { progressions: Object.values(progressions) } : null;
openPopup = () => {
const relevantLocations =
idx(this.props, _ => _.data.transportation.relevantLocations) || [];
if (relevantLocations.length === 1) {
// do not open the modal for only one whitelabel URL (open it directly)
const whitelabelURL =
idx(relevantLocations, _ => _[0].whitelabelURL) || '';
const location = idx(relevantLocations, _ => _[0].location.location);
if (location != null) {
this.openTransportationMap({ location, whitelabelURL });
} else {
navigator.geolocation.getCurrentPosition(position => {
this.openTransportationMap({
location: {
lat: position.coords.latitude,
lng: position.coords.longitude,
},
dateTime={
idx(event, _ => _.start.dateTime) ||
idx(event, _ => _.start.date)
}
>
<span>
{event.start.dateTime
? formatDate(
idx(event, _ => _.start.dateTime.split('T')[0]),
)
: formatDate(idx(event, _ => _.start.date))}
</span>
{idx(event, _ => _.start.dateTime) && (
<span>
{formatTime(
idx(event, _ => _.start.dateTime.split('T')[1]),
)}
</span>
)}
))}
{currentEvents.map(event => (
<div>
<dt data-test="event-summary">
{event.summary}
</dt>
{event.location && (
<span>
<span>{event.location}</span>
</span>
)}
<dd>
<time datetime="{"> _.start.dateTime) ||
idx(event, _ => _.start.date)
}
>
<span>
{event.start.dateTime
? formatDate(
idx(event, _ => _.start.dateTime.split('T')[0]),
)
: formatDate(idx(event, _ => _.start.date))}
</span>
{idx(event, _ => _.start.dateTime) && (
<span>
{formatTime(
idx(event, _ => _.start.dateTime.split('T')[1]),
)}
</span></time></dd></div>
{currentEvents.map(event => (
<div>
<dt data-test="event-summary">
{event.summary}
</dt>
{event.location && (
<span>
<span>{event.location}</span>
</span>
)}
<dd>
<time datetime="{"> _.start.dateTime) ||
idx(event, _ => _.start.date)
}
>
<span>
{event.start.dateTime
? formatDate(
idx(event, _ => _.start.dateTime.split('T')[0]),
)
: formatDate(idx(event, _ => _.start.date))}
</span>
{idx(event, _ => _.start.dateTime) && (
<span>
{formatTime(
idx(event, _ => _.start.dateTime.split('T')[1]),
)}
</span>
)}</time></dd></div>
export async function _flowSemverForRootPath(rootPath: string, reporter: Reporter): Promise {
const configDir = await flowConfigCache.getConfigDir(rootPath);
reporter.info('Determining the version of flow for your project...');
if (!configDir) {
reporter.error('No valid .flowconfig was found. Use `flow init` in the root of your project to create one.');
return;
}
const configPath = path.join(configDir, '.flowconfig');
const {pkg, path: pkgPath} = await readPkgUp({cwd: rootPath});
let packageFlowVersion;
const depRange = idx(pkg, _ => _.dependencies['flow-bin']);
const devDepRange = idx(pkg, _ => _.devDependencies['flow-bin']);
if (depRange && semver.validRange(depRange)) {
packageFlowVersion = depRange;
} else if (devDepRange && semver.validRange(devDepRange)) {
packageFlowVersion = devDepRange;
}
if (packageFlowVersion) {
reporter.info(`Found flow version requirement ${packageFlowVersion} in your package.json`);
}
let configFlowVersion;
if (configDir) {
try {
const configFileStr = await fs.readFile(configPath, 'utf-8');
const flowConfig = ini.parse(configFileStr);
if (typeof flowConfig.version === 'object') {
const rawConfigVersion = Object.keys(flowConfig.version)[0];
const process = error => {
if (_.isNil(error)) {
return
}
const name = idx(error, _ => _.body.name) || idx(error, _ => _.response.result.name) || idx(error, _ => _.name)
let code = idx(error, _ => _.response.result.status) || idx(error, _ => _.body.code) || idx(error, _ => _.code)
let message =
idx(error, _ => _.response.result.message) || idx(error, _ => _.body.message) || idx(error, _ => _.message)
let stack = idx(error, _ => _.response.result.stack) || idx(error, _ => _.body.stack) || idx(error, _ => _.stack)
if (_.isString(stack)) {
stack = [stack]
}
if (!_.isNil(code)) {
code = {code} ::
}
if (!_.isNil(message)) {
message = <b>{message}</b>
}
if (!_.isNil(stack)) {
reqOptions.data = options.body;
}
if (!extraRequestOptions.hasOwnProperty('timeout') && ConnectionStatus.isOffline()) {
reqOptions.timeout = 1;
}
reqOptions = merge({}, reqOptions, extraRequestOptions, uploadOptions);
let response;
let result;
try {
response = await axios.request(reqOptions);
result = response.data;
} catch (e) {
const maybeErrorData = idx(e, _ => _.response.data.errors.length);
if (maybeErrorData) {
result = e.response.data;
} else {
throw e;
}
}
if (result.errors && result.errors.length) {
let responseError = result.errors[0];
let error = new ApiV2Error(responseError.message, responseError.code);
error.serverStack = responseError.stack;
error.details = responseError.details;
throw error;
}
return returnEntireResponse ? response : result.data;
function getIntervals(
definition: DestinyRecordDefinition,
record: DestinyRecordComponent
): RecordInterval[] {
const intervalDefinitions = idx(definition, (d) => d.intervalInfo.intervalObjectives) || [];
const intervalObjectives = idx(record, (r) => r.intervalObjectives) || [];
if (intervalDefinitions.length !== intervalObjectives.length) {
return [];
}
const intervals: RecordInterval[] = [];
let isPrevIntervalComplete = true;
let prevIntervalProgress = 0;
for (let i = 0; i < intervalDefinitions.length; i++) {
const def = intervalDefinitions[i];
const data = intervalObjectives[i];
intervals.push({
objective: data,
score: def.intervalScoreValue,
percentCompleted: isPrevIntervalComplete
reporter: Reporter,
): Promise {
const configDir = await flowConfigCache.getConfigDir(rootPath);
reporter.info('Determining the version of flow for your project...');
if (!configDir) {
reporter.error(
'No valid .flowconfig was found. Use `flow init` in the root of your project to create one.',
);
return null;
}
const configPath = path.join(configDir, '.flowconfig');
const {pkg} = await readPkgUp({cwd: rootPath});
let packageFlowVersion;
const depRange = idx(pkg, _ => _.dependencies['flow-bin']);
const devDepRange = idx(pkg, _ => _.devDependencies['flow-bin']);
if (depRange && semver.validRange(depRange)) {
packageFlowVersion = depRange;
} else if (devDepRange && semver.validRange(devDepRange)) {
packageFlowVersion = devDepRange;
}
if (packageFlowVersion) {
reporter.info(
`Found flow version requirement ${packageFlowVersion} in your package.json`,
);
}
let configFlowVersion;
if (configDir) {
try {
const configFileStr = await fs.readFile(configPath, 'utf-8');
const flowConfig = ini.parse(configFileStr);