Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fractal-objects

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fractal-objects

Fractal Objects

  • 0.10.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Fractal Objects

npm version Twitter Follow

Installation

Install Fractal Objects to the development dependencies of your project:

# With NPM
npm install --save-dev fractal-objects

# With Yarn
yarn add fractal-objects --dev

Usage

import { fold } from 'fractal-objects';

// Fractal object #1
const part1 = { arrayKey: [1], objectKey: { a: 'a', b: 'b' } };
// Fractal object #2
const part2 = { arrayKey: [2, 3], objectKey: { c: 'c' } };
// Fractal object #3
const part3 = { arrayKey: [4] }

// View multiplication of the fractal objects #1, #2, and #3
console.log(fold([part1, part2, part3]));
// Output:
// { arrayKey: [ 1, 2, 3, 4 ], objectKey: { a: 'a', b: 'b', c: 'c' } }

Concept

A fractal object is an object that has self-similarity at lower scales. Multiplication of two fractal objects results in a new fractal object that has the same shape as the original ones.

If we multiply fractal objects in a list pairwise, we'll receive a new fractal object, which will represent all the fractal objects in the list and which will also have the same shape.

By default, the multiplication function provided by the fractal-objects package multiplies two objects by concatenating their array values, merging object values, and replacing scalars with values from the second multiplied object.

Any other multiplication function can be used if it has the following properties:

  1. It keeps the object shape: The multiplicands and the result must have the same shape and type.
  2. It's associative. For example, multiplying (a b) c must have the same result as multiplying a (b c).
  3. It must yield the result a when multiplying undefined a or a undefined.

In terms of mathematics, fractal objects are a [semigroup].

License

Copyright © 2018 SysGears (Cyprus) Limited. This source code is licensed under the MIT license.

Keywords

FAQs

Package last updated on 19 May 2022

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