@cloudcare/browser-core 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,21 +7,23 @@ exports.BoundedBuffer = void 0;
7
7
 
8
8
  var _tools = require("./tools");
9
9
 
10
+ var BUFFER_LIMIT = 500;
11
+
10
12
  var _BoundedBuffer = function _BoundedBuffer() {
11
13
  this.buffer = [];
12
14
  };
13
15
 
14
16
  _BoundedBuffer.prototype = {
15
- add: function add(item) {
16
- var length = this.buffer.push(item);
17
+ add: function add(callback) {
18
+ var length = this.buffer.push(callback);
17
19
 
18
- if (length > this.limit) {
20
+ if (length > BUFFER_LIMIT) {
19
21
  this.buffer.splice(0, 1);
20
22
  }
21
23
  },
22
- drain: function drain(fn) {
23
- (0, _tools.each)(this.buffer, function (item) {
24
- fn(item);
24
+ drain: function drain() {
25
+ (0, _tools.each)(this.buffer, function (callback) {
26
+ callback();
25
27
  });
26
28
  this.buffer.length = 0;
27
29
  }
@@ -1,20 +1,21 @@
1
1
  import { each } from './tools';
2
+ var BUFFER_LIMIT = 500;
2
3
 
3
4
  var _BoundedBuffer = function _BoundedBuffer() {
4
5
  this.buffer = [];
5
6
  };
6
7
 
7
8
  _BoundedBuffer.prototype = {
8
- add: function add(item) {
9
- var length = this.buffer.push(item);
9
+ add: function add(callback) {
10
+ var length = this.buffer.push(callback);
10
11
 
11
- if (length > this.limit) {
12
+ if (length > BUFFER_LIMIT) {
12
13
  this.buffer.splice(0, 1);
13
14
  }
14
15
  },
15
- drain: function drain(fn) {
16
- each(this.buffer, function (item) {
17
- fn(item);
16
+ drain: function drain() {
17
+ each(this.buffer, function (callback) {
18
+ callback();
18
19
  });
19
20
  this.buffer.length = 0;
20
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-core",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "scripts": {
@@ -20,5 +20,5 @@
20
20
  "author": "dataflux",
21
21
  "license": "MIT",
22
22
  "description": "DataFlux RUM Web 端数据指标监控",
23
- "gitHead": "e8411cbf5448e90b81a5e902c54cceb44e6e2501"
23
+ "gitHead": "dc666f91dcd821cc1286ed76b5162d7ce71c7fda"
24
24
  }
@@ -1,18 +1,20 @@
1
1
  import { each } from './tools'
2
+ var BUFFER_LIMIT = 500
3
+
2
4
  var _BoundedBuffer = function () {
3
5
  this.buffer = []
4
6
  }
5
7
  _BoundedBuffer.prototype = {
6
- add: function (item) {
7
- var length = this.buffer.push(item)
8
- if (length > this.limit) {
8
+ add: function (callback) {
9
+ var length = this.buffer.push(callback)
10
+ if (length > BUFFER_LIMIT) {
9
11
  this.buffer.splice(0, 1)
10
12
  }
11
13
  },
12
14
 
13
- drain: function (fn) {
14
- each(this.buffer, function (item) {
15
- fn(item)
15
+ drain: function () {
16
+ each(this.buffer, function (callback) {
17
+ callback()
16
18
  })
17
19
  this.buffer.length = 0
18
20
  }