0.11.0 • Published 6 months ago

tyfell v0.11.0

Weekly downloads
-
License
BSD-2-Clause
Repository
-
Last release
6 months ago

tyfell

utility library for type safe and null safe and declarative programming on typescript.

example

import { compute, optional, required, throws } from 'tyfell'

const Package = (object: unknown) => optional.try(() => compute.object<Package>(object, object => ({
    name: required.string(object['name']),
    version: required.string(object['version']),
    build: optional.number(object['build']),
})))

type Package = {
    name: string
    version: string
    build?: number
}

let package: Package = compute.object(
    optional.try(() => JSON.parse(`{"name":"tyfell","version":"0.0.0"}`)),
    Package,
) ?? throws(Error('json string can not be computed to Package type'))

feature

  • assign: same with Object.assign
  • check: check type and return boolean
  • clone: clone object as shallow or deep
  • compute: check type and run function and return result or return undefined
  • create: create object with source and modification
  • extract: extract from object
  • merge: merge objects
  • optional: check type and return value or return undefined
  • required: check type and return value or throw error
  • throws: throw error

platform

if you transfile tyfell, you can use tyfell on every ecmascript 5 compatible platform.

0.11.0

6 months ago

0.9.7

10 months ago

0.9.4

11 months ago

0.9.3

12 months ago

0.9.6

10 months ago

0.9.5

11 months ago

0.10.0

10 months ago

0.9.0

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.7.1

1 year ago

0.9.2

12 months ago

0.9.1

1 year ago

0.5.0

1 year ago

0.7.0

1 year ago

0.5.2

1 year ago

0.6.0

1 year ago

0.5.1

1 year ago

0.4.2

1 year ago

0.3.0

2 years ago

0.4.1

1 year ago

0.4.0

1 year ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago