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
import { useSlots } from 'vue'; | |
export default function useHasSlot() { | |
const slots = useSlots(); | |
return function hasSlot(name) { | |
return slots[name] && !isEmptySlot(slots[name]()); | |
}; | |
} | |
function isEmptySlot(items) { |
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
export default function ActiveElementObserver (handler = function () {}) { | |
let prev; | |
let raf; | |
this.observe = _ => { | |
cancelAnimationFrame(raf); | |
raf = undefined; | |
if (document.activeElement !== prev) { | |
handler({ activeElement: document.activeElement, prev }); | |
prev = document.activeElement; |
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
function Looper(update, targetFPS = 30, autoplay = true) { | |
let updating = false; | |
this.autoplay = autoplay; | |
this.targetFPS = targetFPS; | |
const advanceFrame = () => { | |
updating = true; | |
const next = () => { | |
const delay = this.autoplay ? 1000 / (this.targetFPS || 30) : 0; | |
setTimeout(() => updating = false, delay); |
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
dat.GUI.prototype.convertToDisplay = function(owner, property) { | |
var field = this.__controllers.find(function(item){return item.property === property}); | |
var parent = field.domElement.parentElement; | |
var value = owner[property]; | |
delete owner[property]; | |
Object.defineProperty(owner, property, { | |
get: function() { | |
return value; | |
}, | |
set: function(newValue) { |
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
// determine if in-browser or using node.js | |
// thruthy | |
var _nodejs = ( | |
typeof process !== 'undefined' && process.versions && process.versions.node); | |
if (_nodejs) { | |
_nodejs = { | |
version: process.versions.node | |
}; | |
} |
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
function transformsSupport() { | |
if (!window.getComputedStyle) { | |
return false; | |
} | |
var el = document.createElement('p'), | |
has3d, | |
transformPropName, | |
transforms = { | |
webkitTransform: '-webkit-transform', |
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
// Welcome! require() some modules from npm (like you were using browserify) | |
// and then hit Run Code to run your code on the right side. | |
// Modules get downloaded from browserify-cdn and bundled in your browser. | |
var iso8601Duration = require('iso8601-duration'); | |
// https://github.com/wking/milliseconds-to-iso-8601-duration/blob/master/milliseconds-to-iso-8601-duration.js | |
var millisecondsToISO8601Duration = function(milliseconds) { | |
if (milliseconds == 0) { | |
return 'P0D'; |
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-console */ | |
const originalConsoleError = console.error; | |
export function restoreConsoleError() { | |
console.error = originalConsoleError; | |
} | |
export function createSuppressedConsoleError(ignoreThese = []) { | |
if (console.error === originalConsoleError) { | |
console.error = (...args) => { |
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 createDomElementPropType = (isRequired = false) | |
=> (props, propName, componentName) | |
=> { | |
if (isRequired && !props[propName]) { | |
return new Error(`${componentName}: prop '${propName}' is required, must be a dom Element`); | |
} | |
if (!props[propName] instanceof Element) { | |
return new Error(`${componentName}: invalid prop '${propName}', must be a dom Element`); | |
} | |
}; |
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
#!/bin/bash | |
USER=; | |
PAGE=1; | |
curl "https://api.github.com/users/$USER/repos?page=$PAGE&per_page=100" | | |
grep -e 'git_url*' | | |
cut -d \" -f 4 | | |
xargs -L1 git clone |
NewerOlder