This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class v extends i.Component { | |
constructor(...e) { | |
super(...e), | |
(this._unmounted = !1), | |
(this._inPTR = !1), | |
(this._pullHeight = 0), | |
(this.state = { | |
pull: 0, | |
pullDistance: 0, | |
}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const odiff = require("odiff"); | |
/** | |
* changeText uses odiff to write a minimal string diff to an automerge.Text. | |
*/ | |
const changeText = (base, newValue) => { | |
const diff = odiff([...base.toString()], [...newValue]); | |
for (const patch of diff) { | |
switch (patch.type) { | |
case "add": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Automerge = require("@automerge/automerge"); | |
const fs = require("fs"); | |
const bytes = fs.readFileSync(process.argv[2]); | |
let doc = Automerge.load(bytes); | |
let msg; | |
let peer = Automerge.init(); | |
let docSync = Automerge.initSyncState(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-loop-func */ | |
const Automerge = require("@automerge/automerge"); | |
const assert = require("node:assert"); | |
const fs = require("fs"); | |
function verify(document, unchecked = false) { | |
return Automerge.load(Automerge.save(document), { unchecked }); | |
} | |
const brokenDoc = process.argv[2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2021 Palantir Technologies, Inc. All rights reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static load(token) { | |
return new Promise((resolve, reject) => { | |
this._createQuery().get(token).then((data) => { | |
resolve(new this(data)); | |
}, (err) => { | |
if (err.code === 101) { | |
resolve(null); // model with token does not exist. | |
} else { | |
reject(new Error(err)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static createProxyFromModel(model) { | |
return new Proxy(model, { | |
get: function(target, name) { | |
if (name in model.definition) { | |
return model.get(name); | |
} else { | |
return target[name]; | |
} | |
}, | |
set: function(target, name, value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Session extends BaseModel { | |
get definition() { | |
return { | |
user: 'string', | |
expirationTime: 'date' | |
}; | |
} | |
// "instance methods" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Session = mongoose.model('Session', { | |
user: String, | |
expirationTime: Date | |
}); | |
// "instance methods" | |
Session.methods.expire = function() { ... }; | |
Session.methods.renew = function(date) { ... }; | |
// "class methods" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var session = yield Session.generate({ user: 'stephen' }); | |
var token = session.token; | |
session.expirationTime = Date.now(); | |
yield session.save(); | |
// re-fetch | |
var fetchedSession = yield Session.load(token); |
NewerOlder