Commit 258e6177 authored by James's avatar James

Rename package from static-sum-type to stags

parent c03ef697
Pipeline #41597487 failed with stage
in 1 minute
...@@ -23,7 +23,7 @@ Here is an example of a valid `Maybe` type ...@@ -23,7 +23,7 @@ Here is an example of a valid `Maybe` type
``` ```
Keep in mind lowercase properties other than `name` are ignored. If you want your type to have static functions or other data you can safely do so as long as the property is a `LowercaseString` Keep in mind lowercase properties other than `name` are ignored. If you want your type to have static functions or other data you can safely do so as long as the property is a `LowercaseString`
You can safely add static methods or properties to your type structure without interfing with `static-sum-type` provided they do not start with a capital letter. You can safely add static methods or properties to your type structure without interfing with `stags` provided they do not start with a capital letter.
> 💡 Any keys in a call to `getOwnPropertyNames(Type)` where `key[0] == key[0].toUpperCase()` will be treated as a case. > 💡 Any keys in a call to `getOwnPropertyNames(Type)` where `key[0] == key[0].toUpperCase()` will be treated as a case.
......
{ {
"name": "static-sum-type", "name": "stags",
"version": "1.0.0-rc2", "version": "1.0.0-rc2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
...@@ -2590,7 +2590,7 @@ ...@@ -2590,7 +2590,7 @@
"execa": { "execa": {
"version": "0.10.0", "version": "0.10.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz", "resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz",
"integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==", "integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfstagsFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==",
"requires": { "requires": {
"cross-spawn": "^6.0.0", "cross-spawn": "^6.0.0",
"get-stream": "^3.0.0", "get-stream": "^3.0.0",
...@@ -6316,4 +6316,4 @@ ...@@ -6316,4 +6316,4 @@
} }
} }
} }
} }
\ No newline at end of file
{ {
"name": "static-sum-type", "name": "stags",
"version": "1.0.0-rc2", "version": "1.0.0-rc3",
"description": "An underlying format for algebraic types that can be used directly or composed with other libraries.", "description": "An underlying format for algebraic types that can be used directly or composed with other libraries.",
"main": "dist/sst.min.js", "main": "dist/stags.min.js",
"unpkg": "dist/sst.min.js", "unpkg": "dist/stags.min.js",
"module": "lib/index.js", "module": "lib/index.js",
"files": [ "files": [
"dist", "dist",
...@@ -50,4 +50,4 @@ ...@@ -50,4 +50,4 @@
"concurrently": "^4.1.0", "concurrently": "^4.1.0",
"rollup-plugin-terser": "^3.0.0" "rollup-plugin-terser": "^3.0.0"
} }
} }
\ No newline at end of file
# static-sum-type # stags
[![pipeline status](https://gitlab.com/JAForbes/static-sum-type/badges/master/pipeline.svg)](https://gitlab.com/JAForbes/static-sum-type/commits/master) [![pipeline status](https://gitlab.com/JAForbes/stags/badges/master/pipeline.svg)](https://gitlab.com/JAForbes/stags/commits/master)
[![coverage report](https://gitlab.com/JAForbes/static-sum-type/badges/master/coverage.svg)](https://gitlab.com/JAForbes/static-sum-type/commits/master) [![coverage report](https://gitlab.com/JAForbes/stags/badges/master/coverage.svg)](https://gitlab.com/JAForbes/stags/commits/master)
## A simple library for complex logic. ## A simple library for complex logic.
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
#### Quick Start #### Quick Start
```bash ```bash
npm install static-sum-type@next npm install stags@next
``` ```
```js ```js
import { either } from "static-sum-type"; import { either } from "stags";
// Create specific types for specific scenarios. // Create specific types for specific scenarios.
const Loaded = const Loaded =
...@@ -61,10 +61,10 @@ Depending on a specific combination of these boolean flags you need to render _d ...@@ -61,10 +61,10 @@ Depending on a specific combination of these boolean flags you need to render _d
It very quicky becomes a mess. We reach for complex tools to help us manage the mess. But instead all we needed was to make it impossible to not traverse every single state. It very quicky becomes a mess. We reach for complex tools to help us manage the mess. But instead all we needed was to make it impossible to not traverse every single state.
First step. Create a `static-sum-type` for every state we want to track. First step. Create a `stags` for every state we want to track.
```js ```js
import { either } from 'static-sum-type' import { either } from 'stags'
const [Selected, Loaded, Modified, Saved] = const [Selected, Loaded, Modified, Saved] =
['Selected', 'Loaded', 'Modified', 'Saved'].map(either) ['Selected', 'Loaded', 'Modified', 'Saved'].map(either)
...@@ -103,10 +103,10 @@ var saved = false ...@@ -103,10 +103,10 @@ var saved = false
var data = x var data = x
``` ```
We'd model that in `static-sum-type` like so: We'd model that in `stags` like so:
```js ```js
import { either } from 'static-sum-type' import { either } from 'stags'
const [Selected, Loaded, Modified, Saved] = const [Selected, Loaded, Modified, Saved] =
['Selected', 'Loaded', 'Modified', 'Saved'].map(either) ['Selected', 'Loaded', 'Modified', 'Saved'].map(either)
...@@ -166,25 +166,25 @@ f( data ) ...@@ -166,25 +166,25 @@ f( data )
If we pass the wrong data structure into our composition, we will get a specific, helpful error message explaining what your type looked like If we pass the wrong data structure into our composition, we will get a specific, helpful error message explaining what your type looked like
and what that particular method was expecting. and what that particular method was expecting.
Your stack trace is going to be particularly legible because `static-sum-type` internally avoids point free composition. Your stack trace is going to be particularly legible because `stags` internally avoids point free composition.
Every error that `static-sum-type` yields, is itself a transformation of Every error that `stags` yields, is itself a transformation of
a `static-sum-type`. All the error types are documented in the [Errors section](#errors) a `stags`. All the error types are documented in the [Errors section](#errors)
#### Specification #### Specification
`static-sum-type` differentiates itself by documenting the internal structure used for types and instances of types. This allows you to create your `stags` differentiates itself by documenting the internal structure used for types and instances of types. This allows you to create your
own constructors/transformers in userland. You can store the exact output own constructors/transformers in userland. You can store the exact output
of a static-sum-type constructor in a `redux-store`, `localStorage` or even a `json` column in `postgres`. of a stags constructor in a `redux-store`, `localStorage` or even a `json` column in `postgres`.
`static-sum-type` does not care where your data came from, just that it adheres to a particular structure. `stags` does not care where your data came from, just that it adheres to a particular structure.
#### Ecosystem #### Ecosystem
Each module listed here adheres to the static-sum-type specification. That specification is defined at [static-sum-type/docs/spec.md](https://gitlab.com/JAForbes/static-sum-type/tree/master/docs/spec.md). Each module listed here adheres to the stags specification. That specification is defined at [stags/docs/spec.md](https://gitlab.com/JAForbes/stags/tree/master/docs/spec.md).
- [superouter](https://gitlab.com/harth/superouter/) A Router that both exposes and internally uses static-sum-type to model route definitions, validation and more. - [superouter](https://gitlab.com/harth/superouter/) A Router that both exposes and internally uses stags to model route definitions, validation and more.
#### Project Goals and Motivations #### Project Goals and Motivations
...@@ -193,9 +193,9 @@ Each module listed here adheres to the static-sum-type specification. That speci ...@@ -193,9 +193,9 @@ Each module listed here adheres to the static-sum-type specification. That speci
- Tiny for frontend usage - Tiny for frontend usage
- Avoid pitfalls found in other sum type libraries - Avoid pitfalls found in other sum type libraries
#### How does static-sum-type differ from other libraries in the ecosystem? #### How does stags differ from other libraries in the ecosystem?
`static-sum-type` removes the following features because we believe they lead to brittle codebases. `stags` removes the following features because we believe they lead to brittle codebases.
- placeholder cases - placeholder cases
- auto spreading of values in cata/fold - auto spreading of values in cata/fold
...@@ -203,7 +203,7 @@ Each module listed here adheres to the static-sum-type specification. That speci ...@@ -203,7 +203,7 @@ Each module listed here adheres to the static-sum-type specification. That speci
- prototypes (reference equality checks / instanceof) - prototypes (reference equality checks / instanceof)
- serializable / useable with Redux/meiosis etc - serializable / useable with Redux/meiosis etc
`static-sum-type` is technically 0KB, it's an idea. You can use static-sum-type in your codebase without ever running `npm install`. `stags` is technically 0KB, it's an idea. You can use stags in your codebase without ever running `npm install`.
### API ### API
...@@ -211,7 +211,7 @@ Each module listed here adheres to the static-sum-type specification. That speci ...@@ -211,7 +211,7 @@ Each module listed here adheres to the static-sum-type specification. That speci
#### either #### either
```js ```js
import { either } from 'static-sum-type' import { either } from 'stags'
const Loaded = const Loaded =
either('Loaded') either('Loaded')
...@@ -244,7 +244,7 @@ const Loaded = ...@@ -244,7 +244,7 @@ const Loaded =
#### `maybe` #### `maybe`
```js ```js
import { maybe } from 'static-sum-type' import { maybe } from 'stags'
const Selected = const Selected =
maybe('Selected') maybe('Selected')
...@@ -277,7 +277,7 @@ const Selected = ...@@ -277,7 +277,7 @@ const Selected =
#### `tagged` #### `tagged`
```js ```js
import { tagged } from 'static-sum-type' import { tagged } from 'stags'
const Geom = const Geom =
tagged ('Geom') ({ tagged ('Geom') ({
...@@ -334,8 +334,8 @@ const StaticSumTypeError = ...@@ -334,8 +334,8 @@ const StaticSumTypeError =
`ExtraCases` | when a fold specifies a visitor for cases that are not of the type. `ExtraCases` | when a fold specifies a visitor for cases that are not of the type.
`MissingCases` | when a fold does not specify a visitor for each case of the type. `MissingCases` | when a fold does not specify a visitor for each case of the type.
`InstanceNull` | when an argument was expected to be an instance of a sum type but was instead null. `InstanceNull` | when an argument was expected to be an instance of a sum type but was instead null.
`InstanceWrongType` | when an instance is a valid `static-sum-type` but not the specifically expected type for that function. `InstanceWrongType` | when an instance is a valid `stags` but not the specifically expected type for that function.
`InstanceShapeInvalid` | when an instance has the correct `type` property but an unknown `case` property. `InstanceShapeInvalid` | when an instance has the correct `type` property but an unknown `case` property.
`NotACaseConstructor` | when a function was expecting a case constructor but received anything else. `NotACaseConstructor` | when a function was expecting a case constructor but received anything else.
`VisitorNotAFunction` | when a function was expected a visitor function but received anything else. `VisitorNotAFunction` | when a function was expected a visitor function but received anything else.
`NotAType` | when a function expected a `static-sum-type` `type` but received anything else. `NotAType` | when a function expected a `stags` `type` but received anything else.
\ No newline at end of file \ No newline at end of file
...@@ -8,9 +8,9 @@ export default { ...@@ -8,9 +8,9 @@ export default {
terser() terser()
], ],
output: { output: {
file: './dist/sst.min.js', file: './dist/stags.min.js',
format: 'umd', format: 'umd',
name: 'sst', name: 'stags',
sourcemap: 'external' sourcemap: 'external'
}, },
......
...@@ -72,7 +72,7 @@ var Maybe2 = { ...@@ -72,7 +72,7 @@ var Maybe2 = {
} }
} }
test('static-sum-type', function (t) { test('stags', function (t) {
const foldMaybe = fold(Maybe) const foldMaybe = fold(Maybe)
var maybeToNum = foldMaybe({ var maybeToNum = foldMaybe({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment