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

one-framework

v1.4.6

Published

One framework

Downloads

8

Readme

About One Framework

On framework is built on top of RxJS, Lodash and React.

One framework gives structure to web applications by providing models and collections with a rich API, views with React components, and connects it all to your existing API over a RESTful JSON interface, and Websockets soon.

Within One framework data is represented by models, which can optionally belongs to a collection, that can be created, destroyed, and persisted to the server. models and collections are using RxJS, and they can be subscribed as them. So, any changes is going to be reflected on view state, keeping data in sync with the DOM with React components.

Sample

  • Source: https://github.com/feliperohdee/one-framework-sample
  • Live Demo (With server render): http://one-framework-sample.herokuapp.com/

Model

A model manages entity properties, and takes care to broadcast changes along other application entities. Furthermore can sync with a backend through a REST API.

Collections

Collections helps you to group models, and encapsulate actions for them, like create, destroy. Further, it can sort models.

Model API

Properties

  • cid: string = Defines an unique identifier for each model instance, it is automatically attributed during model construction. Is highly recommended to never override this property.
  • collection: collection: Defines what collection this model should belongs to. If a model is created through a collection, this property is defined automatically. When this property is defined, any changes is going to be reflected at collection. If this property is defined during model construction, the model is automatically added to collection.
  • resource: string = Defines the resource which this model belongs to at backend, if the model belongs to a collection, this property should not be filled.
  • defaults:{[key: string]: any} = Defines default properties values.
  • validate: (attributes: any) => {[invalid: string]: string} = A function that should be executed to validate model.
  • parse: (attributes: any) => any = A Function that should be executed to parse model's properties.
  • idAttribute: string (default: 'id') = Defines what property that is going to be used to uniquely identify the model.
  • lastSet: number = Read only property that changes along models changes.
  • sync: Sync (default: ajax) = Defines what sync model will use to communicate with backend.
  • updateStream: Subject = An Observable of models' changes.
  • id: string | number = The property which uniquely identify the model, if idAttribute is defined, model.id will return idAttribute property.
  • url: string = Read only property which retrieves related app url followed by their resource, or collection's resource, if applied.

Methods

  • constructor(attributes?: any) = model's constructor.
  • set(newAttributes: any, options?: ISetOptions): model = Create or update model's properties.
  • unset(attribute: string): model = Opposed of set, it unset a model's property.
  • destroy(): model = Destroy the model.
  • fetch(options?: IFetchOptions, useSocket?: boolean): Observable = Fetch a model from backend.
  • save(useSocket?: boolean): Observable = Persists the model at backend.
  • patch(attributes: any, useSocket?: boolean): Observable = Patch the model at backend (send just desired properties, not all whole model).
  • delete(useSocket?: boolean): Observable = Delete the model at backend.
  • get(attribute?: string): any = Get a property from model, following Lodash's get signature.
  • has(attribute: string): boolean = Test if a property exists at model, following Lodash's has signature.
  • keys(): Array = Retrieve just model's keys.
  • values(): Array = Retrieve just model's values.
  • pick(...values: Array): any = Pick just desired model's properties, following Lodash's pick signature.
  • omit(...values: Array): any = Opposed of pick, following Lodash's pick signature.
  • equals(key: string, value: any | Array): boolean = Test if a property is equals a value or values.
  • extend(value: {[key: string]: any}): model = Extend model's properties following Lodash's extend signature.
  • chain(): _.LoDashExplicitObjectWrapper = Returns a Chainable Lodash Object.

Collection API

Properties

  • cid: string = Defines an unique identifier for each collection instance, it is automatically attributed during collection construction. Is highly recommended to never override this property.

  • id: string | number = Different of model, collection.id is an optional property that defines an id which represents the collection on backend post collection.resource. At this way, the collection's url is going to be defined as http(s?)://app.url/collection.resource/collection.id

  • model: typeof model = Defines what kind of model the collection will carry.

  • defaultOrder: {[key: string]: 'asc' | 'desc'} = Defines the default model's order.

      defaultOrder = {
        someProp: 'asc'
      }
  • resource: string = Defines the resource which this collection belongs to at backend. At this way, the collection's url is going to be defined as http(s?)://app.url/collection.resource/collection.id.

  • lastSet: number = Read only property that changes along models changes.

  • sync: Sync = Defines what sync model will use to communicate with backend.

  • updateStream: Subject<IcollectionOperation> = An Observable of models' changes.

  • url: string = Read only property which retrieves related app url followed by their resource, and id if provided.

Methods

  • constructor(model: typeof model, models?: Array | M | Array | any) = collection's constructor.
  • get(id?: string | number): Array = Retrieve all models or a single one identified by their model.id or model.cid.
  • getOne(id?: string | number): M = Get a single model identified by their model.id or model.cid.
  • has(id: string | number): boolean = Test if a model exists in a collection.
  • set(models: Array | M | Array | any, options?: ISetOptions): collection = Create or update a single model or a group of models.
  • reset(): void = Reset a collection and makes it empty.
  • destroy(): collection = Destroy a collection, not their models.
  • fetch(options?: IFetchOptions, useSocket?: boolean): Observable = Fetch models at backend defined by collection's url.
  • orderBy(iteratees?: Array | string, orders?: Array | string): Array = Returns a sorted collection's copy.
  • map(iteratee: ((model: M, index: number) => void) | string): Array = Project collection's models like Array.map and follows Lodash's map signature.
  • reduce(iteratee: (reduction: Array, model: any, index?: number) => Array): Array = Reduce collection's models like Array.reduce and follows Lodash's reduce signature.
  • each(iteratee: (model: M, index: number) => void): void - Iterate collection's models like Array.forEach and follows Lodash's each signature.
  • invokeMap(path: string, ...args: Array): Array = Invoke collection's following Lodash's reduce signature.
  • every(predicate: Function | {[key: string]: any} | string): boolean = Checks if predicate returns truthy for all models of collection, following Lodash's every signature.
  • some(predicate: Function | {[key: string]: any} | string): boolean = Checks if predicate returns truthy for any model of collection, following Lodash's some signature.
  • max(predicate: string): M = Computes the maximum value of models of collection, following Lodash's max signature.
  • min(predicate: string): M = Computes the minimum value of models of collection, following Lodash's min signature.
  • keyBy(predicate: Function | string): {[key: string]: any} = Creates an object composed of keys generated from the results of running each model of collection thru predicate, following Lodash's keyBy signature.
  • groupBy(predicate: Function | string): {[key: string]: Array} = Creates an object composed of keys generated from the results of running each model of collection thru predicate, following Lodash's groupBy signature.
  • filter(predicate: Function | {[key: string]: any} | string): Array = Filter collection's models like Array.filter and follows Lodash's filter signature.
  • reject(predicate: Function | {[key: string]: any} | string): Array = Opposed of filter and follows Lodash's reject signature.
  • find(predicate: Function | {[key: string]: any} | string, last?: boolean): M = Find a model inside a collection following Lodash's find signature.
  • findIndex(predicate: Function | {[key: string]: any} | string, last?: boolean): number = Find a model index inside a collection following Lodash's findIndex signature.
  • first(): M = Retrieves the first model.
  • last(): M = Retrieves the last model.
  • initial(amount?: number): Array = Retrieves the first amount model.
  • tail(amount?: number): Array = Retrieves the last amount model.
  • size(): number = Returns collection's models length.
  • chain(): _.LoDashExplicitArrayWrapper = Returns a Chainable Lodash Object.