Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
intertype
Advanced tools
A JavaScript type checker with helpers to implement own types and do object shape validation.
Table of Contents generated with DocToc
types.isa.integer 42
types.isa.even.integer -42
types.isa.odd.integer 41
types.isa.negative1.integer -42
types.isa.negative0.integer 0
types.isa.positive1.integer 42
types.isa.positive0.integer 0
types.isa.list_of.integer [ 42, ]
types.isa.nonempty.list_of.negative1.integer [ -42, ]
types.isa.nonempty.list_of.negative0.integer [ 0, ]
types.isa.nonempty.list_of.positive1.integer [ 42, ]
types.isa.nonempty.list_of.positive0.integer [ 0, ]
types.isa.empty.list_of.integer []
types.isa.nonempty.list_of.integer [ 42, ]
types.isa.optional.integer 42
types.isa.optional.list_of.integer [ 42, ]
types.isa.optional.empty.list_of.integer []
types.isa.optional.nonempty.list_of.integer [ 42, ]
types.isa.optional.negative1.integer -42
types.isa.optional.negative0.integer 0
types.isa.optional.positive1.integer 42
types.isa.optional.positive0.integer 0
types.isa.optional.nonempty.list_of.negative1.integer [ -42, ]
types.isa.optional.nonempty.list_of.negative0.integer [ 0, ]
types.isa.optional.nonempty.list_of.positive1.integer [ 42, ]
types.isa.optional.nonempty.list_of.positive0.integer [ 0, ]
types.isa.optional.empty.list_of.negative1.integer -42
types.isa.optional.empty.list_of.negative0.integer 0
types.isa.optional.empty.list_of.positive1.integer 42
types.isa.optional.empty.list_of.positive0.integer 0
[all] [all] [isa_collection] [isa_collection] [isa_numeric] [isa_numeric] [mandatory]
————————————————————————————————————————————————————————————————————————————————————————————————————
isa optional empty list_of even negative0 <type>
validate nonempty odd negative1
positive0
positive1
'use strict'
types = new ( require '../../../apps/intertype' ).Intertype()
{ isa
declare } = types
log = console.log
declare 'xy_quantity', test: [
( x ) -> @isa.object x
( x ) -> @isa.float x.value
( x ) -> @isa.nonempty.text x.unit
]
# can use simplified form:
declare.xy_quantity,
test: [
( x ) -> @isa.object x
( x ) -> @isa.float x.value
( x ) -> @isa.nonempty.text x.unit
]
log '^1-1^', isa.xy_quantity null
log '^1-1^', isa.xy_quantity 42
log '^1-1^', isa.xy_quantity { value: 42, unit: 'm', }
picomatch
https://github.com/micromatch/picomatch)isa.integer.or.optional.nonempty.text
odd
, even
; valid for float
s but do imply those numbers will be integergroups
property is itself, so group collection
is
groupmember of group collection
, meaning there are tests for isa.collection
, isa.empty.collection
and so on."empty x
, only for empty.collection x
, empty.any x
&canything
: ( x ) -> true
something
: ( x ) -> x?
nothing
: ( x ) -> not x?
validate.$TYPE ( cfg = { defaults.$TYPE..., cfg..., } )
as
cfg = types.get_defaults.$TYPE cfg
defaults
parameter to declare
defaults
must be retrievable so they can be referenced from new type declarationsnumber
to real
? to avoid conflict with JS Number
and to clarify that this does
not cover imaginary, complex numbers. Observe we now have BigInt
s
pre-generating literally hundreds of hedgpath chainstest
, should be name of type)hengist/dev/intertype
types.declare.empty.list
? types.declare 'empty', 'list'
?isa.$TYPE x, cfg
API? or isa.$TYPE P..., x
where P may be any
number of modifiers as in isa.list 'optional', 'empty', x
Reflect.has()
to check for property availability in size_of()
Reflect.has()
balks on
primitive values like numbers, too, which further complicates the code instead of making it simpler.
⁂sigh⁂isa[ typename ]
(i.e. isa.integer &c
) and validate[ typename ]
,
implement the same for declare
as in declare.my_type cfg
FAQs
A JavaScript typechecker
The npm package intertype receives a total of 164 weekly downloads. As such, intertype popularity was classified as not popular.
We found that intertype demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.