This file contains hidden or 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 toString = str => (typeof str === 'function' ? str.name : String(str)); | |
| export function getLogger(...names: (string | Function)[]): Logger { | |
| return createLogger(names.map(toString)); | |
| } | |
| interface Logger { | |
| info(message: string, ...args: any[]): void; | |
| debug(message: string, ...args: any[]): void; | |
| warn(message: string, ...args: any[]): void; |
This file contains hidden or 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
| /** | |
| * # prosemirror-changeset | |
| * This is a helper module that can turn a sequence of document changes into a set of insertions and deletions, for example to display them in a change-tracking interface. Such a set can be built up incrementally, in order to do such change tracking in a halfway performant way during live editing. | |
| * This code is licensed under an MIT licence. | |
| * ## Programming interface | |
| * Insertions and deletions are represented as ‘spans’—ranges in the document. The deleted spans refer to the original document, whereas the inserted ones point into the current document. | |
| * It is possible to associate arbitrary data values with such spans, for example to track the user that made the change, the timestamp at which it was made, or the step data necessary to invert it again. | |
| * | |
| * Based on last [commit made Mar 12, 2019](https://github.com/ProseMirror/prosemirror-changeset/tree/11cb7b1fc05357c0bac5c444eab48748e4c8aa3b) */ |
This file contains hidden or 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
| /** | |
| * @template T | |
| * @param {Iterable<T>} original | |
| * @param {Iterable<T>} updated | |
| */ | |
| function diffSets(original, updated) { | |
| const toRemove = new Set(original); | |
| const toAdd = new Set(); | |
| // compare which items are new to us | |
| for (const id of updated) { |
This file contains hidden or 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
| /** | |
| * Check the equality of anything | |
| * | |
| * **Example return** | |
| * | |
| * { "permissions.foo": [{}, { "a": 1 }] } | |
| * | |
| * @param {any} obj1 | |
| * @param {any} obj2 |
This file contains hidden or 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
| /** Lazy promise fetch will reuse promise if one was already created */ | |
| export function lazy<F extends () => Promise<any>>(f: F): F { | |
| let once: ReturnType<F> | undefined | |
| // @ts-ignore | |
| return function () { | |
| // @ts-ignore | |
| if (once === undefined) once = f.apply(this, arguments) | |
| return once | |
| } | |
| } |
This file contains hidden or 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
| use std::fmt::{self, Write}; | |
| use std::sync::atomic::AtomicUsize; | |
| use tracing; | |
| use tracing::field::{Field, Visit}; | |
| use tracing::Subscriber; | |
| use tracing_subscriber; | |
| use tracing_subscriber::layer::*; | |
| use tracing_subscriber::registry::*; | |
| use wasm_bindgen::prelude::*; |
This file contains hidden or 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
| git config core.hooksPath .githooks/ | |
| chmod +x .githooks/pre-commit |
This file contains hidden or 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
| use std::{fmt, mem, ops::Deref}; | |
| pub struct Tracked<T: ?Sized>(InnerTrackedState, T); | |
| #[derive(PartialEq)] | |
| enum InnerTrackedState { | |
| New, | |
| Modified, | |
| NoChanges, | |
| } |
This file contains hidden or 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
| //! A small change tracker to wrap around a unique so you can determine if the value changes between updates. | |
| use crate::prelude::*; | |
| use std::{fmt, ops::Deref, ops::DerefMut}; | |
| pub struct TrackedUnique<T: ?Sized>(InnerTrackedState, T); | |
| pub type TrackedUniqueView<'a, T> = UniqueView<'a, TrackedUnique<T>>; | |
| pub type TrackedUniqueViewMut<'a, T> = UniqueViewMut<'a, TrackedUnique<T>>; |