View useful-types.ts
/**
* Types representing having no value for various reasons.
*/
export type nothing = null | undefined | void;
export function isNothing(v: whatever): v is nothing {
return v === null || v === undefined;
}
/**
* Falsy in JS isn't always what you want. Somethings aren't nothings.
View GenericMappedTypes.ts
type Fn<RV, ARGS = any[]> = (...args: ARGS) => RV;
type Maybe<T> = {
// * Mapped types would no longer be limited to a single property map expression. But for each key, only the
// first expression that matches the key would be used.
// * `keyof SOURCE_TYPE extending NARROW_TYPE` is narrowing expression to limit which keys of SOURCE_TYPE
// are enumerated. Only keys having a type that can extend the NARROW_TYPE are enumerated.
// * The syntax for a mapped property type would be extended to allow a generic type declaration, this allows
// the generic to represent the actual concrete type of the key and then be passed along to the type of the
// mapped property.
View Maybe.ts
import { something, defined, TypeGuard, FunctionCall0, FunctionCall1, FunctionCall2, FunctionCall3, FunctionCall4 } from "./UtilityTypes";
import { isObject, whatever } from "./index";
/**
* Maybe.ts - A TypeScript implementation of the Maybe Monad.
* ==========================================================
*
* Usually a Maybe is strong type with methods, but that approach, I felt,
* would lead to poor performance characteristics and also not take full
* advantage of TypeScript's specific approach to types using type guards.
View 0_Intro.md

ItemType Generic Utility Type

This is to describe the situation where one might want to use the type of an array indirectly.

The ItemType generic is sugar over an existing capability in TypeScript to access the type information of the Array generic and make accessing that type more legible to the reader. But a few people replied with "huh, I don't think you want to do that", and to their point, I agree... mostly.

It's almost always better to declare a variable to be of the Array's type directly.

View SubsetTree.ts
import { Queue } from "typescript-collections";
const subsetFunctions = new WeakMap<SubsetTree<any>, IsSubsetFunction<any>>();
const subsetMemos = new WeakMap<IsSubsetFunction<any>, WeakMap<any, WeakMap<any, boolean>>>();
/**
* A subset tree self organizes new nodes such that they will be added to place
* in the tree where it is guaranteed that all nodes in the tree that have
* values that are subsets of the value in the new node are descendants of that
View IdentityDictionary.ts
import {
Dictionary,
} from "typescript-collections";
/**
* This data structure is effectively a Set but it is optimized for
* retrieving the instance associated with the set's identity key.
*
* If an instance implements this interface, the function will be used to
* create it's key value by the default implementation. Otherwise a custom
View css-blocks-form-example.md

An example of a simple form

Consider the following markup:

<form class="root" state:theme=dark state:compact>
  <div class="input-area">
    <label for="username" class="label">Username:</label>
    <input id="username" class="input" type="text">
  </div>
View ChromeUserAgent.css
@namespace "http://www.w3.org/1999/xhtml";
html {
display: block;
}
head {
display: none;
}
View Cascade.ts
import * as parse5 from "parse5";
import * as postcss from "postcss";
import * as CSSselect from "css-select";
import * as specificity from "specificity";
import * as propParser from "css-property-parser";
type Document = parse5.AST.HtmlParser2.Document;
type Node = parse5.AST.HtmlParser2.Node;
type ParentNode = parse5.AST.HtmlParser2.ParentNode;
type HtmlElement = parse5.AST.HtmlParser2.Element;
View typedAssert.ts
import { assert } from "chai";
export function isDefined<X>(value: X | undefined): {and: (cb: (defValue: X) => any) => void } {
if (value) {
return {
and: function(cb: (v: X) => void) {
cb(value);
}
};
} else {