@swim/core
The @swim/core framework provides a lightweight, portable, dependency-free, and strongly typed baseline on which to build higher level libraries. @swim/core forms the foundation on which the @swim/mesh multiplexed streaming WARP framework, and the @swim/ui real-time user interface toolkits, are built. @swim/core is a part of the broader @swim/system framework.
Framework
The @swim/core umbrella package depends on, and re-exports, the following component libraries:
- @swim/util (npm, doc) – ordering, equality, and hashing; type conversions; iterators; builders; maps; caches; and assertions.
- @swim/codec (npm, doc) – incremental I/O; functional parsers and writers; display, debug, and diagnostic formatters; and Unicode and binary codecs.
- @swim/mapping (npm, doc) – functional maps, interpolators, and scales.
- @swim/collections (npm, doc) – immutable, structure sharing collections, including B-trees and S-trees (sequence trees).
- @swim/constraint (npm, doc) – incremental solver for systems of linear constraint equations.
- @swim/structure (npm, doc) – generic structured data model, with support for selectors, expressions, and lambda functions. Used as a common abstract syntax tree for Recon, JSON, XML, and other data languages.
- @swim/streamlet (npm, doc) – stateful, streaming component model for application componets that continuously consume input state from streaming inlets, and continuously produce output state on streaming outlets.
- @swim/dataflow (npm, doc) – compiler from @swim/structure expressions to live-updated data models.
- @swim/recon (npm, doc) – object notation with attributes, like if JSON and XML had a baby.
- @swim/uri (npm, doc) – rich object model for working with Uniform Resource Identifiers and URI subcomponents, including an efficient and safe codec for parsing and writing compliant URI strings.
- @swim/math (npm, doc) – mathematical and geometric structures and operators.
- @swim/geo (npm, doc) – geospatial coordinate, projection, and geometry types.
-
@swim/time
(npm,
doc) –
date-time, time zone, and time interval data types,
with
strptime
/strftime
-style parsers and formatters.
@swim/core has no external dependencies.
Installation
npm
For an npm-managed project, npm install @swim/core
to make it a dependency.
TypeScript sources will be installed into node_modules/@swim/core/main
.
Transpiled JavaScript and TypeScript definition files install into
node_modules/@swim/core/lib/main
. And a pre-built UMD script, which
bundles all @swim/core component libraries, can be found in
node_modules/@swim/core/dist/main/swim-core.js
.
Browser
Browser applications can load swim-core.js
directly from the SwimOS CDN.
<!-- Development -->
<script src="https://cdn.swimos.org/js/latest/swim-core.js"></script>
<!-- Production -->
<script src="https://cdn.swimos.org/js/latest/swim-core.min.js"></script>
Alternatively, the standalone swim-system.js
script may be loaded
from the SwimOS CDN, which bundles @swim/core together with all other
@swim/system
frameworks.
<!-- Development -->
<script src="https://cdn.swimos.org/js/latest/swim-system.js"></script>
<!-- Production -->
<script src="https://cdn.swimos.org/js/latest/swim-system.min.js"></script>
Usage
ES6/TypeScript
@swim/core can be imported as an ES6 module from TypeScript and other
ES6-compatible environments. All component libraries are re-exported by
the umbrella @swim/core
module.
import * as swim from "@swim/core";
CommonJS/Node.js
@swim/core can also be used as a CommonJS module in Node.js applications.
All component libraries are re-exported by the umbrella @swim/core
module.
var swim = require("@swim/core");
Browser
When loaded by a web browser, the swim-core.js
script adds all component
library exports to the global swim
namespace.
The swim-system.js
script also adds all @swim/core component library
exports to the global swim
namespace, making it a drop-in replacement
for swim-core.js
when additional @swim/system frameworks are needed.