JSPM

@igorskyflyer/odin

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q32682F
  • License MIT

๐Ÿ”ฑ Odin is an Object wrapper that allows you to create objects and set their attributes - all at once! ๐Ÿ”บ

Package Exports

  • @igorskyflyer/odin
  • @igorskyflyer/odin/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@igorskyflyer/odin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Icon of Odin

Odin


๐Ÿ”ฑ Odin is an Object wrapper that allows you to create objects and set their attributes - all at once! ๐Ÿ”บ



๐Ÿ“ƒ Table of Contents



๐Ÿค– Features

  • โšก Fast merge - Assigns all source props to target in one go
  • ๐Ÿ›ก Typeโ€‘safe - Leverages TS generics for compileโ€‘time checks
  • ๐Ÿงฉ Shallow copy - Efficiently copies only topโ€‘level properties
  • ๐Ÿ”„ Inโ€‘place update - Mutates and returns the target object
  • ๐Ÿ“ Clear signature - Simple, predictable API
  • ๐Ÿ“ฆ Zero dependencies - Pure TypeScript, no extras
  • ๐ŸŒ Crossโ€‘platform - Works in browser and Node.js
  • ๐Ÿง  Safe defaults - Handles missing or invalid inputs gracefully


๐Ÿ•ต๐Ÿผ Usage

Install it by executing any of the following, depending on your preferred package manager:

pnpm add @igorskyflyer/odin
yarn add @igorskyflyer/odin
npm i @igorskyflyer/odin


๐Ÿคน๐Ÿผ API

odin(target: object, source: object): object

Assigns all properties of the source object to the target object.


target: object - the target object to copy properties to,

source: object - the source object to copy properties from.


Returns the target object.

If the target object is not provided and empty object is returned.

If the source object is not provided the target object is returned unchanged.


โ„น๏ธ NOTE

Shallow vs deep copy

This function uses the method of shallow copying of the source object, for deep/true copied objects consider using clone.js.

For more info, see, shallow copy vs deep copy.



๐Ÿ—’๏ธ Examples

import { odin } from '@igorskyflyer/odin'

const cloned: object = odin({ a: 1, b: 2 }, { c: 3 }) // returns { a: 1, b: 2, c: 3 }


๐Ÿ“ Changelog

๐Ÿ“‘ The changelog is available here, CHANGELOG.md.



๐Ÿชช License

Licensed under the MIT license which is available here, MIT license.



๐Ÿ’– Support

I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. โ˜•

Donate to igorskyflyer

Thank you for supporting my efforts! ๐Ÿ™๐Ÿ˜Š


@igorskyflyer/common-color

๐ŸŽจ Provides common Color-related TypeScript types. ๐ŸŒˆ


@igorskyflyer/magic-queryselector

๐Ÿช„ A TypeScript-types patch for querySelector/querySelectorAll, make them return types you expect them to! ๐Ÿ”ฎ


@igorskyflyer/upath

๐ŸŽ Provides a universal way of formatting file-paths in Unix-like and Windows operating systems as an alternative to the built-in path.normalize(). ๐Ÿงฌ


@igorskyflyer/strip-yaml-front-matter

๐Ÿฆ“ Strips YAML front matter from a String or a file. ๐Ÿ‘พ


@igorskyflyer/registry-apppaths

๐Ÿช€ A Node.js module for reading the AppPaths registry key on Windows. Useful for retrieving applications that can be launched from the command prompt. ๐Ÿ—ƒ




๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Author

Created by Igor Dimitrijeviฤ‡ (@igorskyflyer).