Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blacklane/sarcastic

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blacklane/sarcastic - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

2

index.js

@@ -5,3 +5,3 @@ 'use strict';

/*::
type Assertion<T> = (val: mixed, name: string) => T;
export type Assertion<T> = (val: mixed, name: string) => T;
type AssertionMap = { [key: string]: Assertion<any> };

@@ -8,0 +8,0 @@ type ExtractAssertionType = <T>(Assertion<T>) => T;

{
"name": "@blacklane/sarcastic",
"version": "1.5.0",
"version": "1.5.1",
"description": "Cast unknown values to typed values",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -203,10 +203,22 @@ # Sarcastic

```js
(is('a', is.literal/*::<'a'> */('a')) // returns 'a'
is(42, is.literal/*::<'a'> */('a'), '42') // throws instanceof is.AssertionError
is('a', is.literal('a')) // returns 'a'
is(42, is.literal('a')) // throws instanceof is.AssertionError
```
**With strict typing:**
```js
let literalAssetion = is.literal<'a'>('a');
// or if syntax above doesn't work due to JSX, Prettier, ESLint etc
import { type Assertion } from 'sarcastic';
let literalAssetion: Assertion<'a'> = is.literal('a');
is('a', literalAssetion) // returns 'a'
is(42, is.literal<'a'>('a')) // throws instanceof is.AssertionError
```
### `is.literals(arrayOfStringLiterals)`
```js
let literalsAssertion = is.literals/*::<'a'|'b'|'c'>*/([
let literalsAssertion = is.literals([
'a', 'b', 'c'

@@ -219,1 +231,18 @@ ]);

```
**With strict typing:**
```js
let literalsAssertion = is.literals<'a'|'b'|'c'>([
'a', 'b', 'c'
]);
// or if syntax above doesn't work due to JSX, Prettier, ESLint etc
import { type Assertion } from 'sarcastic';
let literalsAssertion: Assertion<'a'|'b'|'c'> = is.literals<'a'|'b'|'c'>([
'a', 'b', 'c'
]);
is('a', literalsAssertion) // returns 'a'
is('b', literalsAssertion) // returns 'b'
is('c', literalsAssertion) // returns 'c'
is(42, literalsAssertion) // throws instanceof is.AssertionError
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc