Skip to content

Commit

Permalink
Merge pull request #8 from GoogleChromeLabs/default-export
Browse files Browse the repository at this point in the history
Make default storage area a default export
  • Loading branch information
developit authored Aug 13, 2019
2 parents bd12816 + 094579f commit d4cb63e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "dist/kv-storage-polyfill.js",
"module": "dist/kv-storage-polyfill.mjs",
"scripts": {
"build": "microbundle",
"build": "microbundle -f es && microbundle -f cjs,umd src/cjs.js",
"test": "microbundle && MOZ_HEADLESS=1 karmatic --downlevel --browsers chrome:headless,firefox,sauce-ie-11-win10,sauce-edge-17-win10"
},
"keywords": [
Expand Down
21 changes: 21 additions & 0 deletions src/cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

// Simplify CommonJS and UMD consumption by flattening exports.
import storage, { StorageArea } from './index.js';
storage.default = storage;
storage.StorageArea = StorageArea;
export default storage;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ if (typeof Symbol === 'function' && Symbol.asyncIterator) {
StorageArea.prototype[Symbol.asyncIterator] = StorageArea.prototype.entries;
}

export const storage = new StorageArea(DEFAULT_STORAGE_AREA_NAME);
export default new StorageArea(DEFAULT_STORAGE_AREA_NAME);

async function performDatabaseOperation (area, mode, steps) {
// if (this._databasePromise === null) {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import './_helpers';
import { StorageArea, storage } from '..';
import storage, { StorageArea } from '..';
// import { StorageArea, storage } from '../src';

async function collectAsyncIterator (asyncIterator) {
Expand Down

0 comments on commit d4cb63e

Please sign in to comment.