New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@canvas-js/utils

Package Overview
Dependencies
Maintainers
0
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@canvas-js/utils

## API

0.13.10
Source
npm
Version published
Weekly downloads
309
-64.24%
Maintainers
0
Weekly downloads
 
Created
Source

@canvas-js/utils

API

assert

export function assert(condition: unknown, message?: string): asserts condition {
  if (!condition) {
    throw new Error(message ?? "assertion failed")
  }
}

signalInvalidType

export function signalInvalidType(type: never): never {
  console.error(type)
  throw new TypeError("internal error: invalid type")
}

mapEntries

export const mapEntries = <K extends string, S, T>(object: Record<K, S>, map: (entry: [key: K, value: S]) => T) =>
  Object.fromEntries(Object.entries<S>(object).map(([key, value]) => [key, map([key as K, value])])) as Record<K, T>

mapKeys

export const mapKeys = <K extends string, S, T>(object: Record<K, S>, map: (key: K) => T) =>
  Object.fromEntries(Object.entries<S>(object).map(([key, value]) => [key, map(key as K)])) as Record<K, T>

mapValues

export const mapValues = <K extends string, S, T>(object: Record<K, S>, map: (value: S) => T) =>
  Object.fromEntries(Object.entries<S>(object).map(([key, value]) => [key, map(value)])) as Record<K, T>

FAQs

Package last updated on 09 Jan 2025

Did you know?

Socket

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.

Install

Related posts