Skip to content

Commit

Permalink
add entry point for helpers, package-lock.json
Browse files Browse the repository at this point in the history
  • Loading branch information
gr0uch committed Jul 5, 2017
1 parent 56be5c2 commit 48477df
Show file tree
Hide file tree
Showing 5 changed files with 4,028 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog


### 2.1.2 (2017-07-05)
- Polish: add entry point for optional helpers at `simulacra/helpers`.
- Polish: add `package-lock.json`.


### 2.1.1 (2017-05-03)
- Refactor: improve packaging.
- Refactor: don't make functions in a loop.
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $ npm i simulacra --save

## Synopsis

Simulacra.js returns a DOM Node that updates when its state object changes. Its entire API surface area is a single function (with some optional helpers and symbols), and it does not introduce any new syntax or a template language.
Simulacra.js returns a DOM Node that updates when its state object changes. Its entire API surface area is a single function, and it does not introduce any new syntax or a template language.

It is a fairly [low cost](#benchmarks) abstraction, though it may not be quite as fast as hand-optimized code. What this library emphasizes is making the naïve approach of mutating objects to update state as performant and opaque as possible.

Expand Down Expand Up @@ -108,14 +108,20 @@ There are some special cases for the *change* function:

## Helper Functions

Simulacra.js includes some built-in helper functions for common use cases, such as event listening and animations. They are optional, and included for convenience. To use them, one can define a *change* function like so:
Simulacra.js includes some built-in helper functions for common use cases, such as event listening and animations. They are optionalto use, and are opt-in functionality. To use them, one can define a *change* function like so:

```js
var bindObject = require('simulacra')
var bindEvents = bindObject.bindEvents
var animate = bindObject.animate

// This is a Symbol used to signal that an element should be retained
// in the DOM after its value is unset.
var retainElement = bindObject.retainElement

// Helpers are convenience functions for common features, optional to use.
var helpers = require('simulacra/helpers')
var animate = helpers.animate
var bindEvents = helpers.bindEvents

// Accepts a hash keyed by event names, using this has the advantage of
// automatically removing event listeners, even if the element is still
// in the DOM. The optional second argument is `useCapture`.
Expand Down
2 changes: 2 additions & 0 deletions helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Entry point to the helpers.
module.exports = require('./lib/helpers')
Loading

0 comments on commit 48477df

Please sign in to comment.