Filter types from unknown.
npm add @wopjs/cast
import * as c from "@wopjs/cast";
import { Option } from "@wopjs/tsur";
const dataParser = {
width: c.toNumber,
position: a => Option.from(a, a => a && c.isNumber(a.x) && c.isNumber(a.y)),
metadata: c.toNonEmptyPlainObject,
};
function parseData(data) {
const d = c.asObject(data);
return Object.fromEntries(Object.keys(dataParser).map(k => [k, Option.unwrapOr(dataParser[k](d[k]))]));
}
You can use npm version to bump version.
npm version patch
Push the tag to remote and CI will publish the new version to npm.
git push --follow-tags
If you want to publish the package in CI, you need to set the NPM_TOKEN
secrets in GitHub repository settings. See how to create a NPM access token.