Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
forwardEmits = function (e) {
if (!(e && e.data && _.isString(e.data.__emit_uvm) && (e.data.__id_uvm === id))) { return; }
var args;
try { args = Flatted.parse(e.data.__emit_uvm); }
catch (err) { return bridge.emit(ERROR, err); }
bridge.emit.apply(bridge, args); // eslint-disable-line prefer-spread
},
function unflattenExecutionData (fullExecutionData: IExecutionFlattedResponse): IExecutionResponse {
// Unflatten the data
const returnData: IExecutionResponse = {
...fullExecutionData,
workflowData: fullExecutionData.workflowData as IWorkflowDb,
data: parse(fullExecutionData.data),
};
returnData.finished = returnData.finished ? returnData.finished : false;
if (fullExecutionData.id) {
returnData.id = fullExecutionData.id;
}
return returnData;
}
it('should cache the steps', () => {
const data = parse(localStorage.getItem('rsc_cache'));
expect(data.renderedSteps.length).to.be.equal(2);
});
});
function parseStringified(val: string): MagicalNode {
try {
return flatted.parse(val);
} catch (err) {
console.error("error parsing stringified node:", val);
throw err;
}
}
static deserialise(serialised) {
let event;
try {
const rehydratedEvent = flatted.parse(serialised);
rehydratedEvent.data = rehydratedEvent.data.map((e) => {
if (e && e.message && e.stack) {
const fakeError = new Error(e);
Object.keys(e).forEach((key) => { fakeError[key] = e[key]; });
e = fakeError;
}
return e;
});
event = new LoggingEvent(
rehydratedEvent.categoryName,
levels.getLevel(rehydratedEvent.level.levelStr),
rehydratedEvent.data,
rehydratedEvent.context
);
event.startTime = new Date(rehydratedEvent.startTime);
event.pid = rehydratedEvent.pid;
restoreState = () => {
const gamestateJSON = window.localStorage.getItem('gamestate');
if (gamestateJSON !== null) {
const gamestate = parse(gamestateJSON);
this.props.store.dispatch(sync(gamestate));
}
};
static deserialise(serialised) {
let event;
try {
const rehydratedEvent = flatted.parse(serialised);
rehydratedEvent.data = rehydratedEvent.data.map((e) => {
if (e && e.message && e.stack) {
const fakeError = new Error(e);
Object.keys(e).forEach((key) => { fakeError[key] = e[key]; });
e = fakeError;
}
return e;
});
event = new LoggingEvent(
rehydratedEvent.categoryName,
levels.getLevel(rehydratedEvent.level.levelStr),
rehydratedEvent.data,
rehydratedEvent.context
);
event.startTime = new Date(rehydratedEvent.startTime);
event.pid = rehydratedEvent.pid;
export function unflattenExecutionData(fullExecutionData: IExecutionFlattedDb): IExecutionResponse {
const returnData: IExecutionResponse = Object.assign({}, {
id: fullExecutionData.id.toString(),
workflowData: fullExecutionData.workflowData as IWorkflowDb,
data: parse(fullExecutionData.data),
mode: fullExecutionData.mode,
startedAt: fullExecutionData.startedAt,
stoppedAt: fullExecutionData.stoppedAt,
finished: fullExecutionData.finished ? fullExecutionData.finished : false
});
return returnData;
}
readJSON: function ( filePath ) {
return flatted.parse( fs.readFileSync( filePath, {
encoding: 'utf8'
} ) );
},