Skip to content

Commit

Permalink
Prepare release v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jsor committed Aug 19, 2016
1 parent cde069d commit d8831a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
25 changes: 14 additions & 11 deletions dist/carty.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Carty - v0.7.0 - 2016-08-19
* Carty - v0.8.0 - 2016-08-19
* http://sorgalla.com/carty/
* Copyright (c) 2015-2016 Jan Sorgalla; Licensed MIT
*/
Expand Down Expand Up @@ -99,8 +99,8 @@ return /******/ (function(modules) { // webpackBootstrap

var _defaultOptions = {
storage: null,
subtotal: function(items) {
return items.reduce(function(previous, item) {
subtotal: function(cart) {
return cart.items().reduce(function(previous, item) {
return previous + (item.price * item.quantity);
}, 0);
},
Expand Down Expand Up @@ -223,18 +223,20 @@ return /******/ (function(modules) { // webpackBootstrap
return cart;
};

cart.items = function() {
return _items.map(function(item) {
return item();
});
};

cart.quantity = function() {
return _items.reduce(function(previous, item) {
return previous + item().quantity;
}, 0);
};

cart.subtotal = function() {
var items = _items.map(function(item) {
return item();
});

return toNumber(value(_options.subtotal, undefined, [items, cart]), _options);
return toNumber(value(_options.subtotal, undefined, [cart]), _options);
};

cart.shipping = function() {
Expand Down Expand Up @@ -288,7 +290,7 @@ return /******/ (function(modules) { // webpackBootstrap
function load() {
return emit('load').then(function() {
return resolve(
_options.storage && _options.storage.load()
_options.storage && _options.storage.load(cart)
).then(function(items) {
if (type(items) === 'array') {
_items = items.map(function(attr) {
Expand Down Expand Up @@ -423,7 +425,7 @@ return /******/ (function(modules) { // webpackBootstrap
_items.length = 0;

return resolve(
_options.storage && _options.storage.clear()
_options.storage && _options.storage.clear(cart)
).then(emit.bind(cart, 'cleared'), function(e) {
emit('clearfailed', e);
return reject(e);
Expand Down Expand Up @@ -1115,7 +1117,8 @@ return /******/ (function(modules) { // webpackBootstrap
localStorage = localStorage || window.localStorage;

function save(item, cart) {
localStorage.setItem(namespace, JSON.stringify(cart().items));
console.log(cart.items)
localStorage.setItem(namespace, JSON.stringify(cart.items()));
}

function empty() {
Expand Down
Loading

0 comments on commit d8831a4

Please sign in to comment.