Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* @author hex7c0
* @license GPLv3
*/
/*
* initialize module
*/
var backup = require('..');
var assert = require('assert');
var fs = require('fs');
var extname = require('path').extname;
var mongodb = require('mongodb');
var bson = require('bson');
var client = mongodb.MongoClient;
var BSON = new bson.BSON();
var MLong = mongodb.Long;
var BLong = bson.Long;
var Uri = process.env.URI;
var Root = __dirname + '/dump';
var Collection = 'test_10';
/*
* test module
*/
describe('issue10', function() {
var NInt64, SInt64, NLong, SLong;
describe('create new collection', function() {
it('should create long number', function(done) {
* @license GPLv3
*/
/*
* initialize module
*/
var backup = require('mongodb-backup');
var restore = require('..');
var assert = require('assert');
var fs = require('fs');
var extname = require('path').extname;
var mongodb = require('mongodb');
var bson = require('bson');
var client = mongodb.MongoClient;
var BSON = new bson.BSON();
var MLong = mongodb.Long;
var BLong = bson.Long;
var URI = process.env.URI;
var URI2 = process.env.URI2;
var Root = __dirname + '/dump';
var Collection = 'test_8';
/*
* test module
*/
describe('int64 id', function() {
describe('issue8 - parsed as a TimeStamp', function() {
var NInt64, SInt64, NLong, SLong;
it('correctry serialize/deserialize the project', () => {
const comp1 = new Composition()
project.compositions.push(comp1)
const lane1 = new Layer()
comp1.layers.push(lane1)
const pjson = (new BSON()).deserialize(project.serialize())
expect(Project.deserialize(pjson).toJSON()).to.eql(project.toJSON())
})
})
it('correctry serialize/deserialize the project', () => {
const comp1 = new Composition()
project.compositions.push(comp1)
const lane1 = new Layer()
comp1.layers.push(lane1)
const pjson = (new BSON()).deserialize(project.serialize())
expect(Project.deserialize(pjson).toJSON()).to.eql(project.toJSON())
})
})
public serialize()
{
return (new BSON()).serialize(this.toPreBSON())
}
}
import WebSocket from 'isomorphic-ws'
import { BSON, ObjectId, Binary } from 'bson'
import Joi from 'joi'
import { promisify } from 'util'
import EventEmitter from 'events'
import errors from './errors'
export const bson = new BSON()
export const validate = promisify(Joi.validate)
export const noop = () => { }
export const messageSchema = Joi.object().keys({
headers: Joi.object().keys({
'x-seashell-guard': Joi.string().required(),
'x-seashell-connection-id': Joi.string().required(),
'x-seashell-source-socket-id': Joi.string(),
'x-seashell-method': Joi.string(),
'x-seashell-url': Joi.string(),
'x-seashell-status-code': Joi.number(),
'x-seashell-hostname': Joi.string(),
'x-seashell-socket-id': Joi.string(),
}).required(),
body: Joi.any()
})
public serialize()
{
return (new BSON()).serialize(this.toPreBSON())
}
}
public static deserialize(projectBson: Buffer)
{
const projectJson: ProjectScheme = (new BSON()).deserialize(projectBson) as ProjectScheme
const project = new Project()
const assets = projectJson.assets.map(assetJson => Asset.deserialize(assetJson))
const compositions = projectJson.compositions.map(compJson => Composition.deserialize(compJson, project))
project.assets = assets
project.compositions = compositions
return project
}
{
const project = EditorStateStore.getState().get('project')
const projectPath = EditorStateStore.getState().get('projectPath')
if (RendererService.isInRendering) return
if (!project || !projectPath) {
actions.notify(t('letsSave'), '', 'info', 5000)
return
}
const frag = path.parse(projectPath)
const autoSaveFileName = `${frag.name}.auto-saved${frag.ext}`
const autoSavePath = path.join(frag.dir, autoSaveFileName)
const bson = new BSON()
await fs.writeFile(autoSavePath, bson.serialize(project.toPreBSON()))
actions.notify(t('autoSaved', {fileName: autoSaveFileName}), '', 'info', 2000)
},
}
const acceptDiscard = window.confirm('現在のプロジェクトの変更を破棄してプロジェクトを開きますか?')
if (! acceptDiscard) {
return
}
}
const path = remote.dialog.showOpenDialog({
title: 'プロジェクトを開く',
filters: [{name: 'Delir project', extensions: ['delir']}],
properties: ['openFile'],
})
if (! path.length) return
const projectBson = await fs.readFile(path[0])
const projectJson = (new BSON()).deserialize(projectBson)
const migratedProject = Delir.ProjectMigrator.migrate(projectJson)
actions.setActiveProject(Delir.Project.Project.deserialize(migratedProject), path[0])
},