feat(xo-collection): named instead of default exports

Behave better with Babel and native ESM.
This commit is contained in:
Julien Fontanet 2021-05-19 10:58:22 +02:00
parent 8bc2710380
commit 68bb2fa7f0
14 changed files with 21 additions and 20 deletions

View File

@ -33,6 +33,7 @@
>
> In case of conflict, the highest (lowest in previous list) `$version` wins.
- xo-collection minor
- @xen-orchestra/log patch
- xen-api minor
- xo-server-auth-saml minor

View File

@ -1,9 +1,9 @@
import assert from 'assert'
import Collection from 'xo-collection'
import dns from 'dns'
import kindOf from 'kindof'
import ms from 'ms'
import httpRequest from 'http-request-plus'
import { Collection } from 'xo-collection'
import { EventEmitter } from 'events'
import { map, noop, omit } from 'lodash'
import { cancelable, defer, fromCallback, fromEvents, ignoreErrors, pDelay, pRetry, pTimeout } from 'promise-toolbox'

View File

@ -17,7 +17,7 @@ Installation of the [npm package](https://npmjs.org/package/xo-collection):
## Usage
```javascript
var Collection = require('xo-collection')
var { Collection } = require('xo-collection')
```
### Creation
@ -218,7 +218,7 @@ for (const value of col.values()) {
### Views
```javascript
const View = require('xo-collection/view')
const { View } = require('xo-collection/view')
```
> A view is a read-only collection which contains only the items of a

View File

@ -1,5 +1,5 @@
```javascript
var Collection = require('xo-collection')
var { Collection } = require('xo-collection')
```
### Creation
@ -200,7 +200,7 @@ for (const value of col.values()) {
### Views
```javascript
const View = require('xo-collection/view')
const { View } = require('xo-collection/view')
```
> A view is a read-only collection which contains only the items of a

View File

@ -74,7 +74,7 @@ const isValidKey = key => typeof key === 'number' || typeof key === 'string'
// -------------------------------------------------------------------
export default class Collection extends EventEmitter {
export class Collection extends EventEmitter {
constructor() {
super()

View File

@ -3,7 +3,7 @@
import fromEvent from 'promise-toolbox/fromEvent'
import { forEach } from 'lodash'
import Collection, { DuplicateItem, NoSuchItem } from './collection'
import { Collection, DuplicateItem, NoSuchItem } from './collection'
// ===================================================================

View File

@ -7,7 +7,7 @@ import { ACTION_ADD, ACTION_UPDATE, ACTION_REMOVE } from './collection'
// ===================================================================
export default class Index {
export class Index {
constructor(computeHash) {
if (computeHash) {
this.computeHash = iteratee(computeHash)

View File

@ -3,8 +3,8 @@
import fromEvent from 'promise-toolbox/fromEvent'
import { forEach } from 'lodash'
import Collection from './collection'
import Index from './index'
import { Collection } from './collection'
import { Index } from './index'
// ===================================================================

View File

@ -6,7 +6,7 @@ import { ACTION_ADD, ACTION_UPDATE, ACTION_REMOVE } from './collection'
// ===================================================================
export default class UniqueIndex {
export class UniqueIndex {
constructor(computeHash) {
if (computeHash) {
this.computeHash = iteratee(computeHash)

View File

@ -3,8 +3,8 @@
import fromEvent from 'promise-toolbox/fromEvent'
import { forEach } from 'lodash'
import Collection from './collection'
import Index from './unique-index'
import { Collection } from './collection'
import { UniqueIndex } from './unique-index'
// ===================================================================
@ -45,7 +45,7 @@ describe('UniqueIndex', function () {
col.add(item)
})
byKey = new Index('key')
byKey = new UniqueIndex('key')
col.createIndex('byKey', byKey)

View File

@ -1,8 +1,8 @@
/* eslint-disable no-console */
import { forEach } from 'lodash'
import Collection from './collection'
import View from './view'
import { Collection } from './collection'
import { View } from './view'
// ===================================================================

View File

@ -5,7 +5,7 @@ import Collection, { ACTION_ADD, ACTION_UPDATE, ACTION_REMOVE } from './collecti
// ===================================================================
export default class View extends Collection {
export class View extends Collection {
constructor(collection, predicate) {
super()

View File

@ -1,6 +1,6 @@
/* eslint-env jest */
import Xo from 'xo-lib'
import XoCollection from 'xo-collection'
import { Collection as XoCollection } from 'xo-collection'
import { decorateWith } from '@vates/decorate-with'
import { defaultsDeep, find, forOwn, iteratee, pick } from 'lodash'
import { defer } from 'golike-defer'

View File

@ -2,8 +2,7 @@ import Config from '@xen-orchestra/mixins/Config.js'
import Hooks from '@xen-orchestra/mixins/Hooks.js'
import mixin from '@xen-orchestra/mixin'
import mixinLegacy from '@xen-orchestra/mixin/legacy.js'
import XoCollection from 'xo-collection'
import XoUniqueIndex from 'xo-collection/unique-index.js'
import { Collection as XoCollection } from 'xo-collection'
import { createClient as createRedisClient } from 'redis'
import { createDebounceResource } from '@vates/disposable/debounceResource.js'
import { createLogger } from '@xen-orchestra/log'
@ -11,6 +10,7 @@ import { EventEmitter } from 'events'
import { noSuchObject } from 'xo-common/api-errors.js'
import { forEach, includes, isEmpty, iteratee, stubTrue } from 'lodash'
import { parseDuration } from '@vates/parse-duration'
import { UniqueIndex as XoUniqueIndex } from 'xo-collection/unique-index.js'
import mixins from './xo-mixins/index.js'
import Connection from './connection.js'