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
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/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
Consider buying me a coffee. โ
Thank you for supporting my efforts! ๐๐
๐งฌ 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).