Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@
"url": "git://github.com/truqu/purescript-indexedDB.git"
},
"dependencies": {
"purescript-aff": "^4.0.2",
"purescript-datetime": "^3.2.0",
"purescript-eff": "^3.1.0",
"purescript-exceptions": "^3.0.0",
"purescript-foreign": "^4.0.1",
"purescript-maybe": "^3.0.0",
"purescript-nullable": "^3.0.0",
"purescript-prelude": "^3.1.0",
"purescript-read": "^1.0.0"
"purescript-aff": "^5.1.1",
"purescript-datetime": "^4.1.1",
"purescript-effect": "^2.0.1",
"purescript-exceptions": "^4.0.0",
"purescript-foreign": "^5.0.0",
"purescript-maybe": "^4.0.1",
"purescript-nullable": "^4.1.1",
"purescript-prelude": "^4.1.1",
"purescript-read": "^1.0.1"
},
"devDependencies": {
"purescript-now": "^3.0.0",
"purescript-psci-support": "^3.0.0",
"purescript-spec": "^2.0.0",
"purescript-spec-mocha": "^2.0.0"
"purescript-now": "^4.0.0",
"purescript-psci-support": "^4.0.0",
"purescript-spec": "^3.1.0",
"purescript-spec-mocha": "^3.0.0",
"purescript-avar": "^3.0.0"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {},
"devDependencies": {
"bower": "1.8.0",
"bower": "1.8.8",
"eslint": "3.19.0",
"eslint-config-airbnb": "15.0.1",
"eslint-plugin-import": "2.5.0",
Expand All @@ -26,8 +26,8 @@
"karma-mocha": "1.3.0",
"karma-spec-reporter": "0.0.31",
"mocha": "3.4.2",
"pulp": "11.0.0",
"purescript": "0.11.5"
"pulp": "12.3.0",
"purescript": "0.13.3"
},
"repository": {
"type": "git",
Expand Down
16 changes: 2 additions & 14 deletions src/Database/IndexedDB/Core.purs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
-- | The Core module gathers types used across the library and provides basic Show instances for
-- | those types.
module Database.IndexedDB.Core
-- * Effects
( IDB

-- * Types
, Database
( -- * Types
Database
, Index
, KeyCursor
, KeyRange
Expand All @@ -32,21 +29,12 @@ module Database.IndexedDB.Core

import Prelude (class Show)

import Control.Monad.Eff (kind Effect)
import Data.Maybe (Maybe(..))
import Data.String.Read (class Read)

import Database.IndexedDB.IDBKey


--------------------
-- Effects
--

-- | IDB Effects, manifestation that something happened with the IndexedDB
foreign import data IDB :: Effect


--------------------
-- TYPES
--
Expand Down
76 changes: 38 additions & 38 deletions src/Database/IndexedDB/IDBCursor.purs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ module Database.IndexedDB.IDBCursor

import Prelude (Unit, ($), (>>>), (<<<), map)

import Control.Monad.Aff (Aff)
import Control.Monad.Aff.Compat (fromEffFnAff, EffFnAff)
import Data.Foreign (Foreign, toForeign, unsafeFromForeign)
import Effect.Aff (Aff)
import Effect.Aff.Compat (fromEffectFnAff, EffectFnAff)
import Data.Function.Uncurried as Fn
import Data.Function.Uncurried (Fn2, Fn3)
import Data.Maybe (Maybe)
import Data.Nullable (Nullable, toNullable)
import Data.String.Read (read)
import Foreign (Foreign, unsafeToForeign, unsafeFromForeign)

import Database.IndexedDB.Core
import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, toKey, unsafeFromKey)
Expand All @@ -37,55 +37,55 @@ import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, toKey, unsafeFromK

-- | Advances the cursor through the next count records in range.
advance
:: forall e cursor. (IDBCursor cursor)
:: forall cursor. (IDBCursor cursor)
=> cursor
-> Int
-> Aff (idb :: IDB | e) Unit
-> Aff Unit
advance c =
fromEffFnAff <<< Fn.runFn2 _advance c
fromEffectFnAff <<< Fn.runFn2 _advance c


-- | Advances the cursor to the next record in range matching or after key.
continue
:: forall e k cursor. (IDBKey k) => (IDBCursor cursor)
:: forall k cursor. (IDBKey k) => (IDBCursor cursor)
=> cursor
-> Maybe k
-> Aff (idb :: IDB | e) Unit
-> Aff Unit
continue c mk =
fromEffFnAff $ Fn.runFn2 _continue c (toNullable $ map (toKey >>> unsafeFromKey) mk)
fromEffectFnAff $ Fn.runFn2 _continue c (toNullable $ map (toKey >>> unsafeFromKey) mk)


-- | Advances the cursor to the next record in range matching or after key and primaryKey. Throws an "InvalidAccessError" DOMException if the source is not an index.
continuePrimaryKey
:: forall e k cursor. (IDBKey k) => (IDBCursor cursor)
:: forall k cursor. (IDBKey k) => (IDBCursor cursor)
=> cursor
-> k
-> k
-> Aff (idb :: IDB | e) Unit
-> Aff Unit
continuePrimaryKey c k1 k2 =
fromEffFnAff $ Fn.runFn3 _continuePrimaryKey c (unsafeFromKey $ toKey k1) (unsafeFromKey $ toKey k2)
fromEffectFnAff $ Fn.runFn3 _continuePrimaryKey c (unsafeFromKey $ toKey k1) (unsafeFromKey $ toKey k2)


-- | Delete the record pointed at by the cursor with a new value.
delete
:: forall e cursor. (IDBCursor cursor)
:: forall cursor. (IDBCursor cursor)
=> cursor
-> Aff (idb :: IDB | e) Unit
-> Aff Unit
delete =
fromEffFnAff <<< _delete
fromEffectFnAff <<< _delete


-- | Update the record pointed at by the cursor with a new value.
-- |
-- | Throws a "DataError" DOMException if the effective object store uses
-- | in-line keys and the key would have changed.
update
:: forall val e cursor. (IDBCursor cursor)
:: forall val cursor. (IDBCursor cursor)
=> cursor
-> val
-> Aff (idb :: IDB | e) Key
-> Aff Key
update c =
map toKey <<< fromEffFnAff <<< Fn.runFn2 _update c <<< toForeign
map toKey <<< fromEffectFnAff <<< Fn.runFn2 _update c <<< unsafeToForeign


--------------------
Expand All @@ -104,21 +104,21 @@ direction =
-- | Returns the key of the cursor. Throws a "InvalidStateError" DOMException
-- | if the cursor is advancing or is finished.
key
:: forall e cursor. (IDBConcreteCursor cursor)
:: forall cursor. (IDBConcreteCursor cursor)
=> cursor
-> Aff (idb :: IDB | e) Key
-> Aff Key
key =
map toKey <<< fromEffFnAff <<< _key
map toKey <<< fromEffectFnAff <<< _key


-- | Returns the effective key of the cursor. Throws a "InvalidStateError" DOMException
-- | if the cursor is advancing or is finished.
primaryKey
:: forall e cursor. (IDBConcreteCursor cursor)
:: forall cursor. (IDBConcreteCursor cursor)
=> cursor
-> Aff (idb :: IDB | e) Key
-> Aff Key
primaryKey =
map toKey <<< fromEffFnAff <<< _primaryKey
map toKey <<< fromEffectFnAff <<< _primaryKey


-- | Returns the IDBObjectStore or IDBIndex the cursor was opened from.
Expand All @@ -143,24 +143,24 @@ value =
--

foreign import _advance
:: forall cursor e
. Fn2 cursor Int (EffFnAff (idb :: IDB | e) Unit)
:: forall cursor
. Fn2 cursor Int (EffectFnAff Unit)


foreign import _continue
:: forall cursor e
. Fn2 cursor (Nullable Foreign) (EffFnAff (idb :: IDB | e) Unit)
:: forall cursor
. Fn2 cursor (Nullable Foreign) (EffectFnAff Unit)


foreign import _continuePrimaryKey
:: forall cursor e
. Fn3 cursor Foreign Foreign (EffFnAff (idb :: IDB | e) Unit)
:: forall cursor
. Fn3 cursor Foreign Foreign (EffectFnAff Unit)


foreign import _delete
:: forall cursor e
:: forall cursor
. cursor
-> (EffFnAff (idb :: IDB | e) Unit)
-> (EffectFnAff Unit)


foreign import _direction
Expand All @@ -169,15 +169,15 @@ foreign import _direction


foreign import _key
:: forall cursor e
:: forall cursor
. cursor
-> EffFnAff (idb :: IDB | e) Key
-> EffectFnAff Key


foreign import _primaryKey
:: forall cursor e
:: forall cursor
. cursor
-> EffFnAff (idb :: IDB | e) Key
-> EffectFnAff Key


foreign import _source
Expand All @@ -186,8 +186,8 @@ foreign import _source


foreign import _update
:: forall cursor e
. Fn2 cursor Foreign (EffFnAff (idb :: IDB | e) Foreign)
:: forall cursor
. Fn2 cursor Foreign (EffectFnAff Foreign)


foreign import _value
Expand Down
Loading