diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 881a79ee0..89be9549f 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -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 diff --git a/packages/xen-api/src/index.js b/packages/xen-api/src/index.js index 15e3bfb94..98d762521 100644 --- a/packages/xen-api/src/index.js +++ b/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' diff --git a/packages/xo-collection/README.md b/packages/xo-collection/README.md index a090d17b9..ea91b9cbb 100644 --- a/packages/xo-collection/README.md +++ b/packages/xo-collection/README.md @@ -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 diff --git a/packages/xo-collection/USAGE.md b/packages/xo-collection/USAGE.md index 8ff239d34..8b8a0f469 100644 --- a/packages/xo-collection/USAGE.md +++ b/packages/xo-collection/USAGE.md @@ -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 diff --git a/packages/xo-collection/src/collection.js b/packages/xo-collection/src/collection.js index f20d8c751..92e4fbdde 100644 --- a/packages/xo-collection/src/collection.js +++ b/packages/xo-collection/src/collection.js @@ -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() diff --git a/packages/xo-collection/src/collection.spec.js b/packages/xo-collection/src/collection.spec.js index 44d54eea2..43335dcd5 100644 --- a/packages/xo-collection/src/collection.spec.js +++ b/packages/xo-collection/src/collection.spec.js @@ -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' // =================================================================== diff --git a/packages/xo-collection/src/index.js b/packages/xo-collection/src/index.js index 076838747..3769a327f 100644 --- a/packages/xo-collection/src/index.js +++ b/packages/xo-collection/src/index.js @@ -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) diff --git a/packages/xo-collection/src/index.spec.js b/packages/xo-collection/src/index.spec.js index 96c57e601..4c9b603c7 100644 --- a/packages/xo-collection/src/index.spec.js +++ b/packages/xo-collection/src/index.spec.js @@ -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' // =================================================================== diff --git a/packages/xo-collection/src/unique-index.js b/packages/xo-collection/src/unique-index.js index 0e484355e..da7a2b501 100644 --- a/packages/xo-collection/src/unique-index.js +++ b/packages/xo-collection/src/unique-index.js @@ -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) diff --git a/packages/xo-collection/src/unique-index.spec.js b/packages/xo-collection/src/unique-index.spec.js index f9e51a3be..7aecb50ed 100644 --- a/packages/xo-collection/src/unique-index.spec.js +++ b/packages/xo-collection/src/unique-index.spec.js @@ -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) diff --git a/packages/xo-collection/src/view.example.js b/packages/xo-collection/src/view.example.js index eefb69531..9a243088e 100644 --- a/packages/xo-collection/src/view.example.js +++ b/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' // =================================================================== diff --git a/packages/xo-collection/src/view.js b/packages/xo-collection/src/view.js index 4295d674a..85dfb4dd4 100644 --- a/packages/xo-collection/src/view.js +++ b/packages/xo-collection/src/view.js @@ -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() diff --git a/packages/xo-server-test/src/_xoConnection.js b/packages/xo-server-test/src/_xoConnection.js index a778d3b85..d58f7eeff 100644 --- a/packages/xo-server-test/src/_xoConnection.js +++ b/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' diff --git a/packages/xo-server/src/xo.js b/packages/xo-server/src/xo.js index f3b0fe0b9..990848012 100644 --- a/packages/xo-server/src/xo.js +++ b/packages/xo-server/src/xo.js @@ -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'