feat(xo-collection): named instead of default exports
Behave better with Babel and native ESM.
This commit is contained in:
parent
8bc2710380
commit
68bb2fa7f0
@ -33,6 +33,7 @@
|
|||||||
>
|
>
|
||||||
> In case of conflict, the highest (lowest in previous list) `$version` wins.
|
> In case of conflict, the highest (lowest in previous list) `$version` wins.
|
||||||
|
|
||||||
|
- xo-collection minor
|
||||||
- @xen-orchestra/log patch
|
- @xen-orchestra/log patch
|
||||||
- xen-api minor
|
- xen-api minor
|
||||||
- xo-server-auth-saml minor
|
- xo-server-auth-saml minor
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import Collection from 'xo-collection'
|
|
||||||
import dns from 'dns'
|
import dns from 'dns'
|
||||||
import kindOf from 'kindof'
|
import kindOf from 'kindof'
|
||||||
import ms from 'ms'
|
import ms from 'ms'
|
||||||
import httpRequest from 'http-request-plus'
|
import httpRequest from 'http-request-plus'
|
||||||
|
import { Collection } from 'xo-collection'
|
||||||
import { EventEmitter } from 'events'
|
import { EventEmitter } from 'events'
|
||||||
import { map, noop, omit } from 'lodash'
|
import { map, noop, omit } from 'lodash'
|
||||||
import { cancelable, defer, fromCallback, fromEvents, ignoreErrors, pDelay, pRetry, pTimeout } from 'promise-toolbox'
|
import { cancelable, defer, fromCallback, fromEvents, ignoreErrors, pDelay, pRetry, pTimeout } from 'promise-toolbox'
|
||||||
|
@ -17,7 +17,7 @@ Installation of the [npm package](https://npmjs.org/package/xo-collection):
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var Collection = require('xo-collection')
|
var { Collection } = require('xo-collection')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Creation
|
### Creation
|
||||||
@ -218,7 +218,7 @@ for (const value of col.values()) {
|
|||||||
### Views
|
### Views
|
||||||
|
|
||||||
```javascript
|
```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
|
> A view is a read-only collection which contains only the items of a
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
```javascript
|
```javascript
|
||||||
var Collection = require('xo-collection')
|
var { Collection } = require('xo-collection')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Creation
|
### Creation
|
||||||
@ -200,7 +200,7 @@ for (const value of col.values()) {
|
|||||||
### Views
|
### Views
|
||||||
|
|
||||||
```javascript
|
```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
|
> A view is a read-only collection which contains only the items of a
|
||||||
|
@ -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() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import fromEvent from 'promise-toolbox/fromEvent'
|
import fromEvent from 'promise-toolbox/fromEvent'
|
||||||
import { forEach } from 'lodash'
|
import { forEach } from 'lodash'
|
||||||
|
|
||||||
import Collection, { DuplicateItem, NoSuchItem } from './collection'
|
import { Collection, DuplicateItem, NoSuchItem } from './collection'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import { ACTION_ADD, ACTION_UPDATE, ACTION_REMOVE } from './collection'
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
export default class Index {
|
export class Index {
|
||||||
constructor(computeHash) {
|
constructor(computeHash) {
|
||||||
if (computeHash) {
|
if (computeHash) {
|
||||||
this.computeHash = iteratee(computeHash)
|
this.computeHash = iteratee(computeHash)
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
import fromEvent from 'promise-toolbox/fromEvent'
|
import fromEvent from 'promise-toolbox/fromEvent'
|
||||||
import { forEach } from 'lodash'
|
import { forEach } from 'lodash'
|
||||||
|
|
||||||
import Collection from './collection'
|
import { Collection } from './collection'
|
||||||
import Index from './index'
|
import { Index } from './index'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { ACTION_ADD, ACTION_UPDATE, ACTION_REMOVE } from './collection'
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
export default class UniqueIndex {
|
export class UniqueIndex {
|
||||||
constructor(computeHash) {
|
constructor(computeHash) {
|
||||||
if (computeHash) {
|
if (computeHash) {
|
||||||
this.computeHash = iteratee(computeHash)
|
this.computeHash = iteratee(computeHash)
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
import fromEvent from 'promise-toolbox/fromEvent'
|
import fromEvent from 'promise-toolbox/fromEvent'
|
||||||
import { forEach } from 'lodash'
|
import { forEach } from 'lodash'
|
||||||
|
|
||||||
import Collection from './collection'
|
import { Collection } from './collection'
|
||||||
import Index from './unique-index'
|
import { UniqueIndex } from './unique-index'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ describe('UniqueIndex', function () {
|
|||||||
col.add(item)
|
col.add(item)
|
||||||
})
|
})
|
||||||
|
|
||||||
byKey = new Index('key')
|
byKey = new UniqueIndex('key')
|
||||||
|
|
||||||
col.createIndex('byKey', byKey)
|
col.createIndex('byKey', byKey)
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { forEach } from 'lodash'
|
import { forEach } from 'lodash'
|
||||||
|
|
||||||
import Collection from './collection'
|
import { Collection } from './collection'
|
||||||
import View from './view'
|
import { View } from './view'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
@ -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) {
|
constructor(collection, predicate) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-env jest */
|
/* eslint-env jest */
|
||||||
import Xo from 'xo-lib'
|
import Xo from 'xo-lib'
|
||||||
import XoCollection from 'xo-collection'
|
import { Collection as XoCollection } from 'xo-collection'
|
||||||
import { decorateWith } from '@vates/decorate-with'
|
import { decorateWith } from '@vates/decorate-with'
|
||||||
import { defaultsDeep, find, forOwn, iteratee, pick } from 'lodash'
|
import { defaultsDeep, find, forOwn, iteratee, pick } from 'lodash'
|
||||||
import { defer } from 'golike-defer'
|
import { defer } from 'golike-defer'
|
||||||
|
@ -2,8 +2,7 @@ import Config from '@xen-orchestra/mixins/Config.js'
|
|||||||
import Hooks from '@xen-orchestra/mixins/Hooks.js'
|
import Hooks from '@xen-orchestra/mixins/Hooks.js'
|
||||||
import mixin from '@xen-orchestra/mixin'
|
import mixin from '@xen-orchestra/mixin'
|
||||||
import mixinLegacy from '@xen-orchestra/mixin/legacy.js'
|
import mixinLegacy from '@xen-orchestra/mixin/legacy.js'
|
||||||
import XoCollection from 'xo-collection'
|
import { Collection as XoCollection } from 'xo-collection'
|
||||||
import XoUniqueIndex from 'xo-collection/unique-index.js'
|
|
||||||
import { createClient as createRedisClient } from 'redis'
|
import { createClient as createRedisClient } from 'redis'
|
||||||
import { createDebounceResource } from '@vates/disposable/debounceResource.js'
|
import { createDebounceResource } from '@vates/disposable/debounceResource.js'
|
||||||
import { createLogger } from '@xen-orchestra/log'
|
import { createLogger } from '@xen-orchestra/log'
|
||||||
@ -11,6 +10,7 @@ import { EventEmitter } from 'events'
|
|||||||
import { noSuchObject } from 'xo-common/api-errors.js'
|
import { noSuchObject } from 'xo-common/api-errors.js'
|
||||||
import { forEach, includes, isEmpty, iteratee, stubTrue } from 'lodash'
|
import { forEach, includes, isEmpty, iteratee, stubTrue } from 'lodash'
|
||||||
import { parseDuration } from '@vates/parse-duration'
|
import { parseDuration } from '@vates/parse-duration'
|
||||||
|
import { UniqueIndex as XoUniqueIndex } from 'xo-collection/unique-index.js'
|
||||||
|
|
||||||
import mixins from './xo-mixins/index.js'
|
import mixins from './xo-mixins/index.js'
|
||||||
import Connection from './connection.js'
|
import Connection from './connection.js'
|
||||||
|
Loading…
Reference in New Issue
Block a user