Skip to content

Commit

Permalink
feat(xo-collection): named instead of default exports
Browse files Browse the repository at this point in the history
Behave better with Babel and native ESM.
  • Loading branch information
julien-f committed May 19, 2021
1 parent 8bc2710 commit 68bb2fa
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/xen-api/src/index.js
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/xo-collection/README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/xo-collection/USAGE.md
@@ -1,5 +1,5 @@
```javascript
var Collection = require('xo-collection')
var { Collection } = require('xo-collection')
```

### Creation
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/xo-collection/src/collection.js
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion packages/xo-collection/src/collection.spec.js
Expand Up @@ -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'

// ===================================================================

Expand Down
2 changes: 1 addition & 1 deletion packages/xo-collection/src/index.js
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions packages/xo-collection/src/index.spec.js
Expand Up @@ -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'

// ===================================================================

Expand Down
2 changes: 1 addition & 1 deletion packages/xo-collection/src/unique-index.js
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions packages/xo-collection/src/unique-index.spec.js
Expand Up @@ -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'

// ===================================================================

Expand Down Expand Up @@ -45,7 +45,7 @@ describe('UniqueIndex', function () {
col.add(item)
})

byKey = new Index('key')
byKey = new UniqueIndex('key')

col.createIndex('byKey', byKey)

Expand Down
4 changes: 2 additions & 2 deletions packages/xo-collection/src/view.example.js
@@ -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'

// ===================================================================

Expand Down
2 changes: 1 addition & 1 deletion packages/xo-collection/src/view.js
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion packages/xo-server-test/src/_xoConnection.js
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/xo-server/src/xo.js
Expand Up @@ -2,15 +2,15 @@ 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'
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'
Expand Down

0 comments on commit 68bb2fa

Please sign in to comment.