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

sam

v0.0.7

Published

Lightweight framework for the SAM pattern

Downloads

3,263

Readme

SAM-JS

Note: Although this is working, this project is still under development and you should not use it for production because the API may still change.

What is SAM-JS

SAM-JS is a lightweight library for building applications in the SAM architecture.

It intends to extend the discussion about SAM happening in Gitter.

What is SAM

SAM is a new reactive/functional pattern that simplifies Front-End architectures by clearly separating the business logic from the view and, in particular, strictly decoupling back-end APIs from the Front-End. SAM is technology independent and as such can be used to build Web Apps or Native Apps. It is also protocol independent and can be implemented over HTTP, WebSockets...

SAM is unapologetically driven by simplicity and challenges the complexity of frameworks like Google's Angular or Facebook's React+JSX+Flux/Redux+Saga+Thunk+GraphQL+Relay.

more

Developer tools

sam-devtools

Example

Check the working example with devtools.

The gist

Increases the counter by clicking INC. Launches when counter reaches 10.

import { createModel } from 'sam'

// Input: Current store, dataset presented
// Output: New store
const container = (store = {}, dataset = {}) => {
  if (dataset.increaseBy !== undefined) {
    store.counter += dataset.increaseBy
  }
  if (dataset.launch) {
    store.launched = true
  }
  return store
}

// Input: Store (from Model)
// Output: State (to View and nap)
const state = store => {
  return {
    counter: store.counter,
    launchImminent: (store.counter == 9),
    hasLaunched: (store.launched ? true : false),
  }
}

// Input: State
// Output: NAP, i.e. a function which accepts a function (present) and may or may not call it
const nap = state => {
  return present => {
    if (state.counter == 10 && state.hasLaunched != true) {
      present({ launch: true })
    }
  }
}

const initialStore = {
  counter: 0
}

// Input: Model
// Output: Dispatch, i.e. a function which accepts an action and presents values to the model
const createDispatch = present => action => {
  switch (action.type) {
    case 'INC':
      present({ increaseBy: 1 })
      break
  }
}

const model = createModel(container, state, nap, initialStore)
const dispatch = createDispatch(model.present)

// You may render the View however you wish
// e.g. with React
import React from 'react'
import { render } from 'react-dom'
model.subscribe(state => {
  render(
    <App state={state} dispatch={dispatch} />,
      document.getElementById('root')
  )
})

Thanks

  • JJ Dubray for the SAM architecture and starting the discussion around it.
  • Redux for promoting many awesome ideas happening in the community.
  • Jonah Fox for handing over the sam NPM package name.