Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Dec 6, 2017
1 parent 07b66f2 commit 8cf4fec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unistore",
"version": "2.0.1",
"version": "2.1.0",
"description": "Dead simple centralized state container (store) with preact bindings.",
"source": "unistore.js",
"module": "dist/unistore.es.js",
Expand Down
12 changes: 5 additions & 7 deletions unistore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function createStore(state={}) {
return {
setState(update, overwrite) {
state = overwrite ? update : { ...state, ...update };
listeners.forEach( f => { f(state); });
for (let i=0; i<listeners.length; i++) {
listeners[i](state);
}
},
subscribe(f) {
listeners.push(f);
Expand All @@ -40,7 +42,7 @@ export function createStore(state={}) {
* export class Foo { render({ foo, bar }) { } }
*/
export function connect(mapStateToProps, actions) {
if (typeof mapToProps!=='function') mapStateToProps = select(mapStateToProps);
if (typeof mapStateToProps!=='function') mapStateToProps = select(mapStateToProps || []);
return Child => (
class Wrapper extends Component {
constructor(props, { store }) {
Expand Down Expand Up @@ -82,8 +84,7 @@ function mapActions(actions, store) {


// select('foo,bar') creates a function of the form: ({ foo, bar }) => ({ foo, bar })
export function select(properties) {
if (properties==null) return empty;
function select(properties) {
if (typeof properties==='string') properties = properties.split(',');
return state => {
let selected = {};
Expand All @@ -95,9 +96,6 @@ export function select(properties) {
}


const empty = () => ({});


// Returns a boolean indicating if all keys and values match between two objects.
function shallowEqual(a, b) {
for (let i in a) if (a[i]!==b[i]) return false;
Expand Down

0 comments on commit 8cf4fec

Please sign in to comment.