Skip to content

Instantly share code, notes, and snippets.

🍕
please

James jamesplease

🍕
please
Block or report user

Report or block jamesplease

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View react-cache.js
/** @license React v16.6.0
* react-cache.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
@jamesplease
jamesplease / get-ref.js
Created Aug 21, 2018
Store a ref internally, and support consumers accessing the ref as well. Supports function refs and createRef
View get-ref.js
getRef = ref => {
const { nodeRef } = this.props;
if (typeof nodeRef === 'function') {
nodeRef(ref);
} else if (nodeRef && nodeRef.hasOwnProperty('current')) {
nodeRef.current = ref;
}
this.nodeRef = ref;
@jamesplease
jamesplease / api-idea.md
Created Aug 15, 2018
From Stephen R. and Javi P.
View api-idea.md

Passing classNames should append that to every node within the element's tree. For instance, if a React component renders the following DOM tree:

<div className="menu">
  <div className="menu_item">
  </div>
</div>

and a consumer of the library passes className="myCustomMenu" as a prop to that Component, it should now render:

View composer.js
promiseComposer(
[
() => Promise.resolve(2),
([valOne]) => Promise.resolve(valOne * 2),
([valOne, valTwo]) => Promise.resolve(valOne * 2 + valTwo)
]
)
.then(result => console.log('the result', [2, 4, 8]));
View promise-pls.js
// The function
function subscribe(promises, cb) {
let result = Array.from({ length: promises.length }).fill(null);
promises.forEach((promise, index) => {
promise.then(val => {
const clonedResult = [...result];
clonedResult[index] = val;
cb(clonedResult);
result = clonedResult;
View promise-struct.js
{
// The value that the Promise resolved or rejected to
value: any,
// `true` when the Promise has either resolved or rejected
complete: Boolean,
// `true` until the Promise resolves or rejects
pending: Boolean,
// `true` when the Promise is resolved
View tooltip.js
let statusTooltip;
if (processStatus.processing) {
statusTooltip = 'Processing';
} else if (processStatus.processed) {
statusTooltip = 'Processed';
} else if (processStatus.error) {
statusTooltip = 'Error';
}
View animate.js
animate(ref, options) {
if (!ref.current) {
return;
}
options.pre.forEach((val, attr) => {
ref.current.style[attr] = val;
});
requestAnimationFrame(() => {
View svg-attributes.txt
accent-height
additive
alignment-baseline
allowReorder
alphabetic
amplitude
arabic-form
ascent
attributeName
attributeType
View compute-position.js
import rotation from "./rotation";
const coordinatesMap = {
"top-left": [0, 0],
top: [0.5, 0],
"top-right": [1, 0],
left: [0, 0.5],
center: [0.5, 0.5],
right: [1, 0.5],
"bottom-left": [0, 1],
You can’t perform that action at this time.