Skip to content

Instantly share code, notes, and snippets.

View tomaszgil's full-sized avatar
🐐

Tomasz Gil tomaszgil

🐐
View GitHub Profile
const data = {
other: 'skip',
prefix1: 'take1',
prefix2: 'take2',
};
const prefixedValues = Object.entries(data)
// Get only entries with keys staring with prefix
.filter(([key, value]) => key.startsWith('prefix'))
// Get only values
import React, { useRef, useState, useLayoutEffect, useCallback } from "react";
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you 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 distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
function simpleIterator() {
const iterator = {
next() {
return {
value: "Hello, I'm an iterator",
done: true,
};
},
};
const startTimestamp = getMiliseconds();
function getMiliseconds() {
return new Date(Date.now()).getMilliseconds();
}
function getMillisecondsElapsed() {
return getMiliseconds() - startTimestamp;
}