Stack
Module Collections.Stacks
A stack has the logic of a pile of plates. First in, last out. With a stack, you’re only able to work on the top-most, most recently added item.
Immutable
Section titled “Immutable”Stacks.immutable creates an immutable stack of Interface Stacks.IStackImmutable
import { Stacks } from "https://unpkg.com/@ixfx/collections/bundle"
let s = Stacks.immutable();s = s.push(`a`, `b`); // Add two strings
// Peek looks at the top of the stack// (ie most recently added)s.peek; // `b`
// Remove item from top of stacks = s.pop();s.peek // `a`
Mutable
Section titled “Mutable”Stacks.mutable creates a mutable stack of Interface Stacks.IStackMutable
import { Stacks } from "https://unpkg.com/@ixfx/collections/bundle"
const s = Stacks.mutable();s.push(`a`, `b`);s.peek; // `b`s.pop(); // `b`s.peek; // `a`
Importing
Section titled “Importing”// Sub moduleimport { Stacks } from "@ixfx/collections.js"// Eg: Stacks.immutable();
// Whole moduleimport * as Collections from "@ixfx/collections.js"// Eg: Collections.Stacks.immutable();
// From bundleimport { Collections } from "@ixfx"// Eg: Collections.Stacks.immutable();
// And within your HTML's <HEAD> </HEAD> block:<script type="importmap">{ "imports": { "@ixfx":"/ixfx/index.js", "@ixfx/": "/ixfx/" } }</script>
// Sub module from parentimport { Stacks } from "@ixfx/collections.js"// Eg: Stacks.immutable();
// Whole parent moduleimport * as Collections from "@ixfx/collections.js"// Eg: Collections.Stacks.immutable();
// From the bundleimport { Collections } from "@ixfx/bundle.js"// Eg: Collections.Stacks.immutable();
// Sub module from parentimport { Stacks } from "https://unpkg.com/@ixfx/collections/bundle"// Eg: Stacks.immutable();
// Whole parent moduleimport * as Collections from "https://unpkg.com/@ixfx/collections/bundle"// Eg: Collections.Stacks.immutable();
// Single module from the bundleimport { Collections } from "https://unpkg.com/@ixfx/bundle"// Eg: Collections.Stacks.immutable();