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-list

v0.5.1

Published

List Type for Yjs

Downloads

6

Readme

List Type for Yjs

Manage list-like data with this shareable list type. You can insert and delete arbitrary objects (also custom types for Yjs) in the list type.

Use it!

Retrieve this with bower or npm.

Bower
bower install y-list --save

and include the js library.

<script src="./bower_components/y-list/y-list.js"></script>
NPM
npm install y-list --save

and put it on the Y object.

Y.List = require("y-list");

List Object

Reference
  • Create
var ylist = new Y.List()
  • .insert(position, content)
    • Insert content at a position
  • .insertContents(position, contents)
    • Insert a set of content at a position. This expects that contents is an array of content.
  • .push(content)
    • Insert content at the end of the list
  • .delete(position, length)
    • Delete content. The length parameter is optional and defaults to 1
  • .val()
    • Retrieve all content as an Array Object
  • .val(position)
    • Retrieve content from a position
  • .ref(position)
    • Retrieve a reference to the element on a position.
    • You can call ref.getNext() and ref.getPrev() to get the next/previous reference
    • You can call ref.getNext(i) and ref.getPrev(i) to get the i-th next/previous reference
    • You can call ref.val() to get the element, to which the reference points (y.ref(1).val() === y.val(1))
  • .observe(f)
    • The observer is called whenever something on this list changed. (throws insert, and delete events)
  • .unobserve(f)
    • Delete an observer

A note on intention preservation

If two users insert something at the same position concurrently, the content that was inserted by the user with the higher user-id will be to the right of the other content. In the OT world we often speak of intention preservation, which is very loosely defined in most cases. This type has the following notion of intention preservation: When a user inserts content c after a set of content C_left, and before a set of content C_right, then C_left will be always to the left of c, and C_right will be always to the right of c. This property will also hold when content is deleted or when a deletion is undone.

A note on time complexities

  • .insert(position, content)
    • O(position)
  • .insertContents(position, contents)
    • O(position + |contents|)
  • .push(content)
    • O(1)
  • .delete(position, length)
    • O(position)
  • .val()
    • O(|ylist|)
  • .val(position)
    • O(position|)
  • Apply a delete operation from another user
    • O(1)
  • Apply an insert operation from another user
    • Yjs does not transform against operations that do not conflict with each other.
    • An operation conflicts with another operation if it intends to be inserted at the same position.
    • Overall worst case complexety: O(|conflicts|!)

Issues

  • Support moving of objects
  • Create a polymer element

License

Yjs is licensed under the MIT License.

[email protected]