Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function reducer(state = initState, action, store) {
const { type, postBody, body } = action
switch (type) {
//== Initialization. This takes place once every flash loading ==
case '@@Response/kcsapi/api_get_member/require_info': {
const admiralId = body.api_basic.api_member_id
// Load static quest goal data
let questGoals = {}
try {
questGoals = CSON.parseCSONFile(questGoalsPath)
} catch (e) {
console.warn('No quest goal data!')
}
// Load quest tracking of this account
let records = {}
try {
records = CSON.parseCSONFile(questTrackingPath(admiralId))
if (records && records.time) {
records = outdateRecords(questGoals, records, records.time, Date.now())
}
} catch (e) {
console.warn('No quest tracking data!')
}
delete records.time // Time is added ad-hoc upon saving
return {
...state,
const { type, postBody, body } = action
switch (type) {
//== Initialization. This takes place once every flash loading ==
case '@@Response/kcsapi/api_get_member/require_info': {
const admiralId = body.api_basic.api_member_id
// Load static quest goal data
let questGoals = {}
try {
questGoals = CSON.parseCSONFile(questGoalsPath)
} catch (e) {
console.warn('No quest goal data!')
}
// Load quest tracking of this account
let records = {}
try {
records = CSON.parseCSONFile(questTrackingPath(admiralId))
if (records && records.time) {
records = outdateRecords(questGoals, records, records.time, Date.now())
}
} catch (e) {
console.warn('No quest tracking data!')
}
delete records.time // Time is added ad-hoc upon saving
return {
...state,
records,
questGoals,
activeQuests: outdateActiveQuests(state.activeQuests, Date.now()),
}
}
//== Daily update ==
throw new Error(file + ' doesn\'t exist');
}
var ext = path.extname(file);
// YAML file
if (ext.match(/ya?ml/)) {
var res = fs.readFileSync(file, 'utf8');
var yaml = require('js-yaml');
return yaml.safeLoad(res, { schema: yaml.DEFAULT_FULL_SCHEMA });
}
// CSON file
if (ext.match(/cson/)) {
var cson = require('cson');
return cson.parseCSONFile(file);
}
// JS / JSON / CoffeeScript
if (ext.match(/json|js|coffee|ls/)) {
if (!path.isAbsolute(file)) {
file = path.join(process.cwd(), file);
}
return require(file);
}
// unknown
throw new Error(file + ' is an unsupported filetype');
};
constructor() {
super()
this.configData = {}
try {
fs.accessSync(configPath, fs.R_OK | fs.W_OK)
this.configData = mergeConfig(defaultConfig, CSON.parseCSONFile(configPath))
dbg.log(`Config loaded from: ${configPath}`)
} catch (e) {
dbg.log(e)
}
this.defaultConfigData = defaultConfig
}
grunt.registerTask('data', 'build kyujitai.json', function () {
var done = this.async();
var CSON = require('cson');
var fs = require('fs');
var data = {
douon: CSON.parseCSONFile('data/douon.cson'),
kyuji: CSON.parseCSONFile('data/kyuji.cson'),
exclude: CSON.parseCSONFile('data/exclude.cson')
};
fs.writeFile('data/kyujitai.json', JSON.stringify(data), done);
grunt.log.writeln('created data/kyujitai.json');
});
};
files.forEach(file => {
var fileName = path.parse(file).base;
var parsed = cson.parseCSONFile(file);
Object.keys(parsed).forEach(key => {
Object.keys(parsed[key]).forEach(title => {
var s = parsed[key][title];
snippets.push(new Snippet(title, s.body, s.prefix, fileName, key));
});
});
});
grunt.registerTask('data', 'build kyujitai.json', function () {
var done = this.async();
var CSON = require('cson');
var fs = require('fs');
var data = {
douon: CSON.parseCSONFile('data/douon.cson'),
kyuji: CSON.parseCSONFile('data/kyuji.cson'),
exclude: CSON.parseCSONFile('data/exclude.cson')
};
fs.writeFile('data/kyujitai.json', JSON.stringify(data), done);
grunt.log.writeln('created data/kyujitai.json');
});
};
grunt.registerTask('data', 'build kyujitai.json', function () {
var done = this.async();
var CSON = require('cson');
var fs = require('fs');
var data = {
douon: CSON.parseCSONFile('data/douon.cson'),
kyuji: CSON.parseCSONFile('data/kyuji.cson'),
exclude: CSON.parseCSONFile('data/exclude.cson')
};
fs.writeFile('data/kyujitai.json', JSON.stringify(data), done);
grunt.log.writeln('created data/kyujitai.json');
});
};