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

@perfective/object

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@perfective/object

Functions to work with the Object type

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Object

The @perfective/object package provides functions to work with the standard JS Object class.

  • Types:
    • ObjectWithDefined<T, K extends keyof T>
    • ObjectWithUndefined<T, K extends keyof T>
    • ObjectWithNotNull<T, K extends keyof T>
    • ObjectWithNull<T, K extends keyof T>
    • ObjectWithPresent<T, K extends keyof T>
    • ObjectWithAbsent<T, K extends keyof T>
    • RecursivePartial<T>
    • Entry<T = unknown>
  • Unit functions:
    • copy<T>(value: T): T — creates a shallow copy of the given value. (Experimental).
    • clone<T>(value: T): T — creates a clone (deep copy) of the given value. (Experimental).
    • pick<T, K extends keyof T>(record: T, ...property: readonly K[]): Pick<T, K> — creates a copy of the record only with the given property.
    • omit<T, K extends keyof T>(record: T, ...property: readonly K[]): Omit<T, K> — creates a copy of the record without the given property.
    • filter<T, K extends keyof T>(record: T, condition: Predicate<T[K]>): Partial<T> — creates a copy of the record where each value meets the condition.
    • assign<T, V = Partial<T>>(value: T, ...overrides: (V | Partial<T>)[]): T & V — creates a shallow copy of the given value with the given overrides.
    • recordFromArray(array: string[]): Record<string, number>
    • recordFromEntries(entries: Entry[]): Record<string, unknown>
    • recordWithPicked<T, K extends keyof T>(...property: readonly K[]): Unary<T, Pick<T, K>> — partially applies the pick() function for the given property.
    • recordWithOmitted<T, K extends keyof T>(...property: readonly K[]): Unary<T, Omit<T, K>> — partially applies the omit() function for the given property.
    • recordFiltered<T, K extends keyof T = keyof T>(condition: Predicate<T[K]>): Unary<T, Partial<T>> — partially applies the filter() function for the given condition.
  • Type guards:
    • hasDefinedProperty<T, K extends keyof T>(property: K, ...and: readonly K[]): (value: T) => value is ObjectWithDefined<T, K>
    • hasUndefinedProperty<T, K extends keyof T>(property: K, ...and: readonly K[]): (value: T) => value is ObjectWithUndefined<T, K>
    • hasNotNullProperty<T, K extends keyof T>(property: K, ...and: readonly K[]): (value: T) => value is ObjectWithNotNull<T, K>
    • hasNullProperty<T, K extends keyof T>(property: K, ...and: readonly K[]): (value: T) => value is ObjectWithNull<T, K>
    • hasPresentProperty<T, K extends keyof T>(property: K, ...and: readonly K[]): (value: T) => value is ObjectWithPresent<T, K>
    • hasAbsentProperty<T, K extends keyof T>(property: K, ...and: readonly K[]): (value: T) => value is ObjectWithAbsent<T, K>
  • Predicates:
    • isObject<T>(value: T | null): boolean
    • isRecord<T>(value: T): boolean
    • isTruthy<T>(value: T): boolean
    • isFalsy<T>(value: T): boolean
    • isEmpty<T>(value: T): boolean
  • Reducers:
    • toRecordFromEntries(record: Record<string, unknown>, value: Entry): Record<string, unknown>
  • Property functions:
    • property<T, K extends keyof T>(property: K): Unary<T, T[K]>
    • property<T, K extends keyof T>(property: K, condition: Predicate<T[K]>): Predicate<T>
    • by<T, K extends keyof T>(property: K, ordering: Compare<T[K]>): Compare<T>
  • Input:
    • Input<T>
    • InputArray<T>
    • InputObject<T>
    • InputPrimitive<T>
    • input<T>(input: unknown): Input<T> — type cast to Input<T>.
    • stringInput(input: Input<string>): string | undefined
    • numberInput(input: Input<number>): number | undefined
    • booleanInput(input: Input<boolean>): boolean | undefined
    • arrayInput<T>(input: Input<T[]>): Input<T>[] | undefined — checks that the input is an array and returns it as an array of unvalidated elements.
    • objectInput<T>(input: Input<T>): InputObject<T> | undefined — checks that the input is a non-null, non-array object, and returns it as an object with unvalidated properties.
    • nullInput(input: Input<null>): null | undefined.

Read the full documentation in the repository.

Keywords

FAQs

Package last updated on 19 Feb 2021

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

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