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

spacedef

v1.1.12

Published

Functions for working with feld/screen/room proteins and space definitions

Downloads

4

Readme

spacedef

Functions for working with feld/screen/room proteins and spacefiles (space.yaml). Serves as an implementation of the space definition draft (v. 0.7)

This is a pure Javascript lib (users must do their own e.g. file IO)

Functions for working with space definitions

  • validate_viewports_attributes()

      // Returns false if:
      //  - arg null, undefined, not a map, or an empty map
      //  - 'defaults' key is present but nothing else
  • validate_windows_attributes()

      // Returns false if:
      //  - args are null, undefined, not a map, or an empty map
      //  - 'defaults' key is present but nothing else
      //  - any item in windows object lacks 'viewports' list or string
      //  - That list or string mentions a viewport which isn't included
      //    in in the viewports collection
  • validate_space_attributes()

      // Returns false if:
      //  - args are null, undefined, not a map, or an empty map
      //  - machines list not a list, or empty
      //  - machines list has more than one principal=true
        
  • validate_space_defn()

      // Returns false if:
      //  - argumentis null, undefined, not a map, or an empty map
      //  - windows is present but viewports not present
      //  - space is present, but viewports or windows not present
      //  - any section doesn't validate using functions defined above
  • viewports_from_space_defn()

      // Given a space definition returns a valid map of viewport definitions 
      // with all defaults installed but overriden by any local attributes.
      // Global defaults instantiated the same way.
      // norm / over / up vectors are harmonized and any missing filled in.
      // If there is no 'viewports' entry at all, returns a map with one 
      // 'defaultviewport' in it.
      // Any "defaults" section is not returned.
  • windows_from_space_defn()

      // Given a JSON representation of a space.yaml file, 
      // returns a map of window definitions conforming to
      // space.yaml 'windows' definition.
      // If there are "defaults" present, they'll be copied into all entries 
      // in the collection (overriden by more-local attributes).
      // Global defaults instantiated the same way.
      // If there is no 'windows' entry at all, one default 'main' window 
      // will be returned.

Conversion

  • convert_roomfeldscreen_to_space() <<== Spits out a legal space def

      // Given JSON representations of room, feld, and screen proteins,
      // return a JS object representing a valid space.yaml definition,
      // or null on error

Functions for working with feld/screen proteins

  • viewports_from_screen_protein()

      // Given a JSON representation of a screen protein, 
      // returns a map of viewport definitions conforming to
      // space.yaml 'viewports' definition
  • windows_from_feld_protein()

      // Given a JSON representation of a feld protein, 
      // returns a map of window definitions conforming to
      // space.yaml 'window' definition.
      // Works for both regular and kombi.
  • viewports_from_kombi()

      // Given a JSON representation of a kombifeld protein, 
      // returns a JS object (a map) of PARTIAL viewport info -- it's just
      // the info that is novel in the kombifeld file, 
      // found under the "ingests/felds/all/felds" section.
      // Keys are the keys of that section.
      // Values are partial viewport descriptions.
      // We expect the rest of the info about this viewport is in the 
      // screen.protein
  • is_screen_protein()

      // Returns true if JSON representation matches valid screen protein
  • is_feld_protein()

      // Returns true if JSON representation matches valid feld protein
  • is_kombifeld_protein()

      // Given a JSON representation of a kombifeld protein, 
      // returns true if it has the "all" + "kombi" signature 
      // indicating true wild kombifelds
  • fold_kombi_info_into()

      // Given two maps, for any key/object pairs which exist in both,
      // kombi attributes 'sizepx' and 'offsetpx' will be
      // imported from the first into the second.  Returns a new list.
  • window_names_from_feld_protein()

      // Returns a list of all window names
      //  NOTE: assumes kombifelds only EVER have one window, named main.
      // Seems true in practice.

room.protein functions

  • space_from_room_protein()

      //  room.protein has no info about windows, so the windows lists for 
      //  each machine will be EMPTY.

Global defaults

  • default_viewport()
  • default_window()
  • default_space()
  • default_room()