Skip to content

Instantly share code, notes, and snippets.

View fostyfost's full-sized avatar
🤪
All you need is Half-Life 3

Fosty Fost fostyfost

🤪
All you need is Half-Life 3
View GitHub Profile
@fostyfost
fostyfost / property-descriptor-stack.ts
Created September 15, 2023 16:59 — forked from imdfl/property-descriptor-stack.ts
Change property descriptors on an object with an undo stack
interface IPropertyDescriptorStack {
/**
* set the property descriptor of the member prop on the target object
* Fails silently, returning false
* @param props
*/
push(props: Partial<PropertyDescriptor>): boolean;
/**
* reset the property descriptor of the member prop on the target object, either to
* the state it was before the last set, or to the initial state, resetting the state stack.
@fostyfost
fostyfost / README.md
Created April 5, 2023 12:45 — forked from vicapow/README.md
getStyles function from NYT's Crowbar

Get all the styles as a string from a given document. useful for creating a PNG from an SVG. SVG's need to have all of their style information embedded within their document to be properly exported.

Example usage:

var styles = getStyles(window.document);

Try it by going to [http://bl.ocks.org/vicapow/raw/9904319/](this block) and running the above usage example in the console.

@fostyfost
fostyfost / unflat.js
Created December 8, 2020 19:49 — forked from szanata/unflat.js
Unflat js object
function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
function mergeDeep(target, ...sources) {
if (!sources.length) return target;
const source = sources.shift();
if (isObject(target) && isObject(source)) {
for (const key in source) {