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

@faicon/core

v0.2.1

Published

Faicon core API for react. https://github.com/faiconqg/core

Downloads

14

Readme

API

Table of Contents

apiClient

Sets or gets the api client instance

Parameters

  • adapter Adapter
  • options {} (optional, default {})

Returns Adapter

url

Returns the resource's url.

Returns string

isRequest

Questions whether the request exists and matches a certain label

Parameters

Returns boolean

rpc

Call an RPC action for all those non-REST endpoints that you may have in your API.

Parameters

Returns Request

length

Alias for models.length

Returns Number

map

Alias for models.map

Parameters

  • callback function (model: Model): any

Returns Array<any>

forEach

Alias for models.forEach

Parameters

  • callback function (model: Model): void

Returns void

url

Returns the URL where the model's resource would be located on the server.

Returns string

model

Specifies the model class for that collection

Parameters

  • attributes {} (optional, default {})

toJS

Returns a JSON representation of the collection

Returns Array<{}>

toArray

Alias of slice

Returns Array<Model>

slice

Returns a defensive shallow array representation of the collection

Returns Array<Model>

peek

Returns a shallow array representation of the collection

Returns Array<Model>

isEmpty

Wether the collection is empty

Returns boolean

_ids

Gets the ids of all the items in the collection

Returns Array<Id>

at

Get a resource at a given position

Parameters

Returns Model?

get

Get a resource with the given id or uuid

Parameters

  • id Id
  • $1 any (optional, default {})
    • $1.required (optional, default false)

Returns Model?

filter

Get resources matching criteria

Parameters

  • query ({} | function (Model): boolean)

Returns Array<Model>

find

Finds an element with the given matcher

Parameters

  • query ({} | function (Model): boolean)
  • $1 any (optional, default {})
    • $1.required (optional, default false)

Returns Model?

add

Adds a model or collection of models.

Parameters

  • data (Array<({} | Model)> | {} | Model)

Returns void

reset

Resets the collection of models.

Parameters

Returns void

remove

Removes the model with the given ids or uuids

Parameters

  • ids (Id | Model | Array<(Id | Model)>)

Returns void

set

Sets the resources into the collection.

You can disable adding, changing or removing.

Parameters

  • resources Array<{}>
  • $1 any (optional, default {})
    • $1.add (optional, default true)
    • $1.change (optional, default true)
    • $1.remove (optional, default true)

Returns void

build

Creates a new model instance with the given attributes

Parameters

  • attributes {} (optional, default {})

Returns Model

create

Creates the model and saves it on the backend

The default behaviour is optimistic but this can be tuned.

Parameters

  • attributesOrModel ({} | Model)
  • $1 any (optional, default {})
    • $1.optimistic (optional, default true)

Returns Request

fetch

Fetches the models from the backend.

It uses set internally so you can use the options to disable adding, changing or removing.

Parameters

  • options SetOptions (optional, default {})

Returns Request

toJS

Returns a JSON representation of the model

primaryKey

Determine what attribute do you use as a primary id

Returns string

urlRoot

Return the base url used in the url method

url

Return the url for this given REST resource

Returns string

isNew

Wether the resource is new or not

We determine this asking if it contains the primaryKey attribute (set by the server).

Returns boolean

get

Get the attribute from the model.

Since we want to be sure changes on the schema don't fail silently we throw an error if the field does not exist.

If you want to deal with flexible schemas use has to check wether the field exists.

Parameters

Returns any

has

Returns whether the given field exists for the model.

Parameters

Returns boolean

id

Get an id from the model. It will use either the backend assigned one or the client.

Returns Id

changedAttributes

Get an array with the attributes names that have changed.

Returns Array<string>

changes

Gets the current changes.

Returns {}

hasChanges

If an attribute is specified, returns true if it has changes. If no attribute is specified, returns true if any attribute has changes.

Parameters

Returns boolean

reset

Replace all attributes with new data

Parameters

  • data {}

Returns void

set

Merge the given attributes with the current ones

Parameters

  • data {}

Returns void

fetch

Fetches the model from the backend.

Parameters

  • $0 any (optional, default {})
    • $0.data
    • $0.otherOptions ...any

Returns Request

applyPatchChanges

Merges old attributes with new ones. By default it doesn't merge arrays.

Parameters

  • oldAttributes {}
  • changes {}

Returns {}

save

Saves the resource on the backend.

If the item has a primaryKey it updates it, otherwise it creates the new resource.

It supports optimistic and patch updates.

TODO: Add progress

Parameters

  • attributes {}
  • $1 any (optional, default {})
    • $1.optimistic (optional, default true)
    • $1.patch (optional, default true)
    • $1.keepChanges (optional, default true)
    • $1.otherOptions ...any

Returns Request

destroy

Destroys the resurce on the client and requests the backend to delete it there too

Parameters

  • $0 any (optional, default {})
    • $0.optimistic (optional, default true)
    • $0.otherOptions ...any

Returns Request