@igorskyflyer/odin
v2.0.0
Published
🔱 Odin is an Object wrapper that allows you to create objects and set their attributes - all at once! 🔺
Downloads
13
Maintainers
Readme
📃 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/odinyarn add @igorskyflyer/odinnpm i @igorskyflyer/odin🤹🏼 API
odin(target: object, source: object): objectAssigns 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
🧬 Related
🎨 Provides common Color-related TypeScript types. 🌈
@igorskyflyer/magic-queryselector
🪄 A TypeScript-types patch for querySelector/querySelectorAll, make them return types you expect them to! 🔮
🎍 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).
