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
var nodeVersion = parseInt(process.versions.node.split('.')[0]); | |
if (nodeVersion >= 6) { | |
// Use the untranspiled ES6 code | |
require('./src'); | |
} else { | |
// Use the transpiled ES5 code | |
require('./lib'); | |
} |
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
class SocketHandler { | |
get room() { | |
return this.primus.rooms(this.roomName); | |
} | |
constructor(primus, roomName, actionHandlers, disconnectionHandler) { | |
this.primus = primus; | |
this.roomName = roomName; | |
primus.on('connection', (spark) => { |
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
/***************************************************************************** | |
* QuantCup 1: Price-Time Matching Engine | |
* | |
* Submitted by: voyager | |
* | |
* Design Overview: | |
* In this implementation, the limit order book is represented using | |
* a flat linear array (pricePoints), indexed by the numeric price value. | |
* Each entry in this array corresponds to a specific price point and holds | |
* an instance of struct pricePoint. This data structure maintains a list |
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
// Demo: https://codesandbox.io/s/react-numberinput-v5-7lqtb | |
import React, { useEffect, useState } from 'react'; | |
function clamp( | |
x: number, | |
lower: number = Number.NEGATIVE_INFINITY, | |
upper: number = Number.POSITIVE_INFINITY, | |
): number { | |
return Math.min(Math.max(x, lower), upper); |
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
import React from 'react'; | |
// Source: https://github.com/emotion-js/emotion/blob/master/packages/styled-base/types/helper.d.ts | |
type PropsOf< | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
E extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any> | |
> = JSX.LibraryManagedAttributes<E, React.ComponentPropsWithRef<E>>; | |
export interface BoxOwnProps<E extends React.ElementType = React.ElementType> { | |
as?: E; |
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
// ~~: Math.floor | |
// >>> 0: Clamp to Uint32 | |
const PRIME32_1 = 2654435761; // 0b10011110001101110111100110110001 | |
const PRIME32_2 = 2246822519; // 0b10000101111010111100101001110111 | |
const PRIME32_3 = 3266489917; // 0b11000010101100101010111000111101 | |
const PRIME32_4 = 668265263; // 0b00100111110101001110101100101111 | |
const PRIME32_5 = 374761393; // 0b00010110010101100110011110110001 | |
function xxh32(message: Uint8Array, seed: number = 0): number { |
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
// Inspired by: https://github.com/levitation/murmurhash-js | |
function murmur3a(data: string, seed: number = 0): number { | |
const len = data.length; | |
const nBlocks = len >>> 2; | |
const tailOffset = nBlocks << 2; | |
let k1; | |
/* Body */ |
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
function imul2(x, yHi, yLo) { | |
return (((x * yHi) << 16) + x * y) | 0; | |
} | |
function imul(x, y) { | |
return imul2(x, (y >>> 16) & 0xffff, y & 0xffff); | |
} |
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
/* eslint-disable no-fallthrough */ | |
// Inspired by: https://github.com/levitation/murmurhash-js | |
export default function murmur2(data: string, seed: number = 0): number { | |
// 'm' and 'r' are mixing constants generated offline. | |
// They're not really 'magic', they just happen to work well. | |
// const m = 0x5bd1e995; | |
// const r = 24; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer