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 fs = require('fs') | |
const path = require('path') | |
const semver = require('/home/khai/lib/node_modules/semver') | |
const pkgdir = path.join(__dirname, 'packages') | |
for (const pkgname of fs.readdirSync(pkgdir)) { | |
const dirname = path.join(pkgdir, pkgname) | |
const stats = fs.statSync(dirname) | |
if (!stats.isDirectory()) continue | |
const manifest = path.join(dirname, 'package.json') |
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
#! /usr/bin/env node | |
const LIMIT = 256 | |
const range = n => Array(n).fill(0).map((_, i) => i) | |
const unionRange = n => range(n).join(' | ') | |
console.log(`export type Foo<N extends ${unionRange(LIMIT)}> = [`) | |
for (const n of range(LIMIT)) { | |
console.log(` [${range(n).join(', ')}],`) | |
} |
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
#! /usr/bin/env node | |
const LIMIT = 256 | |
const range = n => Array(n).fill(0).map((_, i) => i) | |
const unionRange = n => range(n).join(' | ') | |
console.log(`export type Foo<N extends ${unionRange(LIMIT)}> = `) | |
for (const n of range(LIMIT)) { | |
console.log(` N extends ${n} ? [${range(n).join(', ')}] :`) | |
} |
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
interface MaybeBase { | |
readonly loaded: boolean | |
} | |
interface Some<X> extends MaybeBase { | |
readonly loaded: true | |
readonly value: X | |
} | |
interface None extends MaybeBase { |
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
use core::ops::{Add, Mul}; | |
use core::marker::Copy; | |
use std::fmt::Display; | |
fn compose<X, Y, Z> ( | |
f: impl Fn(X) -> Y, | |
g: impl Fn(Y) -> Z | |
) -> impl Fn(X) -> Z { | |
move |x: X| g(f(x)) | |
} |
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
primes = take 15 (sieve [2..]) | |
sieve (prime:rest) = prime : sieve [x | x <- rest, mod x prime /= 0] |
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
#! /usr/bin/env lsc | |
require! 'path' | |
require! 'fs' | |
const {exists-sync, readlink-sync} = fs | |
const {stdout, stderr, exit, cwd} = require 'process' | |
const {spawn-sync} = require 'child_process' | |
require! 'js-yaml' | |
const {create-command-arguments} = require './lib/shell-command-utils.js' | |
const argv = let |
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
interface XSet<X0> { | |
has<X1 extends X0> (x: X1): this is XSetWith<X1, X0> | |
} | |
interface XSetWith<X1 extends X0, X0> extends XSet<X0> { | |
has<X2 extends X0> (x: X2): this is XSetWith<X2, X1> | |
has<X2 extends X1> (x: X2): true | |
} | |
declare const xset: XSet<number> |
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 namespace TupleUtils { | |
/** | |
* Get type of first element | |
* @example `First<[0, 1, 2]>` → `0` | |
*/ | |
export type First<Tuple extends [any, ...any[]]> = Tuple[0] | |
/** | |
* Get type of last element |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.