npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

y-map

v10.1.3

Published

Map Type for Yjs

Downloads

77

Readme

Map Type for Yjs

Manage map-like data with this shareable map type. You can insert and delete objects in y-map. The objects must either be a custom types, or fulfill the following property: v equals JSON.parse(JSON.stringify(v)) (according to your definition of equality)

Use it!

Retrieve this with bower or npm.

Bower
bower install y-map --save
NPM
npm install y-map --save

Y.Map

Y.Map mimics the behaviour of a javascript Object. You can create, update, and remove properies on this type. Furthermore, you can observe changes on this type as you can observe changes on Javascript Objects with Object.observe - an ECMAScript 7 proposal ~~which is likely to become accepted by the committee~~. Until then, we have our own implementation.

Reference
  • .get(key)
    • Retrieve the value for key
  • .set(key, value)
    • Set/update a property
    • You can also insert a type map.set(key, Y.Map)
    • If not a shared type, the value should fulfill the following property: value equals JSON.parse(JSON.stringify(value)) (according to your notion of equality)
  • .delete(key)
    • Delete a property
  • .keys()
    • Returns all keys for all values
  • .observe(observer)
    • The observer is called whenever something on this object changes. Throws add, update, and delete events
    • The event object has the following properties:
      • event.type The type of the event. "add" - a new key-value pair was added, "update" - an existing key-value pair was changed, or "delete" - a key-value pair was deleted)
      • event.name The key of the changed property
      • event.value If event type is either "update" or "add", this property defines the new value of the key-value pair
      • event.object The object on which the event occurred (The object on which .observe(..) was called)
  • .observeDeep(function observer(event){..})
    • Same as .observe, but catches events from all children (if they support .observeDeep)
    • event.path specifies the path of the change event
  • .observePath(path, observer) deprecated
    • path is an array of property keys
    • observer is when the value under the path is found
    • observer is called when the property under path is set, deleted, or updated
    • returns a function which, if called, removes the observer from the path
  • .unobserve(f)
    • Delete an observer

A note on intention preservation

When users create/update/delete the same property concurrently, only one change will prevail. Changes on different properties do not conflict with each other.

A note on time complexities

  • .get(key)
    • O(1)
  • .set(key, value)
    • O(1)
  • .delete(key)
    • O(1)
  • Apply a delete operation from another user
    • O(1)
  • Apply an update operation from another user (set/update a property)
    • Yjs does not transform against operations that do not conflict with each other.
    • An operation conflicts with another operation if it changes the same property.
    • Overall worst case complexety: O(|conflicts|^)

Changelog

10.0.0

  • inserting & retrieving types are synchronous operations
    • I.e. `y.share.map.get('some type') // => returns a type instead of a promise
  • relies on Yjs@^12.0.0

License

Yjs is licensed under the MIT License.

[email protected]