![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A super-simple JavaScript type checker. Mainly pilfered from this blog post by Webbjocke. No dependencies. 3.6K GCC compiled, 2.0K uncompiled.
Install
npm install typa
Import
import {is} from 'typa'
// or
const is = require('typa')
Checks if value matches the specified type, then returns the first function (or value) if true or the second function (or value) if false.
Method:
is.typa($type, $value, $fn1, $fn2)
Example:
const myString = 'this is a string'
const myArray = 'this is also a string, not an array'
const fn1 = (() => console.log('hello'))
const fn2 = (() => console.log('goodbye'))
is.typa('str', myString, fn1, fn2)
// => 'hello'
is.typa('arr', myArray, fn1, fn2)
// => 'goodbye'
is.arr($value)
Example:
const isArray = is.arr(['text', 12])
// => true
is.bad($value)
Example:
let isBad = is.bad(null)
// => true
isBad = is.bad(undefined)
// => true
isBad = is.bad({})
// => true
isBad = is.bad(new Error('This is an error'))
// => true
is.bool($value)
Example:
let isBool = is.bool(true)
// => true
isBool = is.bool(false)
// => true
is.date($value)
Example:
const isDate = is.date(new Date())
// => true
is.empty($value)
Example:
let isEmpty = is.empty('')
// => true
isEmpty = is.empty([])
// => true
isEmpty = is.empty({})
// => true
is.err($value)
Example:
const isErr = is.err(new Error('This is an error.'))
// => true
is.fn($value)
Example:
const isFn = is.fn(() => { console.log('Hi!') })
// => true
is.int($value)
Example:
const isInt = is.int(12)
// => true
is.json($value)
Example:
const isJson = is.json('{"key": "value"}')
// => true
is.null($value)
Example:
const isNll = is.nll(null)
// => true
is.noru($value)
Example:
let isNoru = is.noru(null)
// => true
isNoru = is.noru(undefined)
// => true
is.num($value)
Example:
const isNum = is.num(28.2)
// => true
is.obj($value)
Example:
const isObj = is.obj({ key: 'value' })
// => true
is.prom($value)
Example:
const myPromise = new Promise((resolve, reject) => {
try {
console.log('I make a promise to you')
resolve()
} catch(err) {
reject(err)
}
})
const isProm = is.prom(myPromise)
// => true
is.regex($value)
Example:
const isRegex = is.regex(new Regex(/\W/))
// => true
is.str($value)
Example:
const isStr = is.str('text')
// => true
is.sym($value)
Example:
const isSym = is.sym(Symbol(42))
// => true
is.undef($value)
Example:
const isUndef = is.undef(undefined)
// => true
FAQs
Super-simple, zero-dependency JavaScript type checker utility.
The npm package typa receives a total of 9 weekly downloads. As such, typa popularity was classified as not popular.
We found that typa demonstrated a not healthy version release cadence and project activity because the last version was released 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.