Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@coderspirit/nominal-inputs
Advanced tools
Nominal-Inputs
is an extension for Nominal
.
# With NPM
npm install @coderspirit/nominal-inputs
# Or with PNPM
pnpm add --save-dev @coderspirit/nominal-inputs
# Or with Yarn:
yarn add --dev @coderspirit/nominal-inputs
Input types are specifically designed to be used for function parameters, and we have to use them in a very specific way. Examples below.
IntegerInput<N>
import type { IntegerInput } from '@coderspirit/nominal-inputs'
// Notice how we have to declare a generic type parameter in order to use
// `IntegerInput`
function onlyAcceptsIntegers<N extends number>(n: IntegerInput<N>): number {
return n
}
// Using the function
onlyAcceptsIntegers(42) // All good :D
onlyAcceptsIntegers(0.5) // Type Error!
SizedStringInput<S>
import type { SizedStringInput } from '@coderspirit/nominal-inputs'
function onlyAcceptsThreeCharStrings<S extends string>(s: SizedStringInput<S, 3>): void {
console.log(s)
}
onlyAcceptsThreeCharStrings("abc") // All good :D
onlyAcceptsThreeCharStrings("ab") // Type Error!
onlyAcceptsThreeCharStrings("abcd") // Type Error!
NegativeInput<N>
NegativeIntegerInput<N>
PositiveInput<N>
PositiveIntegerInput<N>
The tagged types introduced by this package are not "special" as the previously
referred "input types", but they rely on the powerful features of Nominal
.
Use them to track properties that you already verified either statically or at runtime, so you can avoid having to check them again.
TaggedFloat<N>
TaggedInteger<N>
TaggedNegative<N>
TaggedNegativeFloat<N>
TaggedNegativeInteger<N>
TaggedPositive<N>
TaggedPositiveFloat<N>
TaggedPositiveIntegger<N>
FAQs
Extension of @coderspirit/nominal with 'input' types
We found that @coderspirit/nominal-inputs 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.