• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Haixing-Hu / vue3-class-component / 7c8a3f3e-046f-4ced-b630-a0c6636a0ccb

09 Jun 2025 08:22AM UTC coverage: 100.0%. Remained the same
7c8a3f3e-046f-4ced-b630-a0c6636a0ccb

push

circleci

Haixing-Hu
chore: update yarn.lock after dependency changes

151 of 151 branches covered (100.0%)

Branch coverage included in aggregate %.

222 of 222 relevant lines covered (100.0%)

19.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/impl/collect-data.js
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
//    Copyright (c) 2022 - 2024.
4
//    Haixing Hu, Qubit Co. Ltd.
5
//
6
//    All rights reserved.
7
//
8
////////////////////////////////////////////////////////////////////////////////
9
import clone from '@qubit-ltd/clone';
10
import collectMethod from './collect-method';
11

12
/**
13
 * Collects all class fields from an instance of a class and modify the existing
14
 * Vue component options object.
15
 *
16
 * @param {function} Class
17
 *     The constructor of the class being decorated.
18
 * @param {object} defaultInstance
19
 *     the default constructed instance of the decorated class.
20
 * @param {object} options
21
 *     the Vue component options object.
22
 * @private
23
 * @author Haixing Hu
24
 */
25
function collectData(Class, defaultInstance, options) {
26
  // Collect the class fields
27
  const entries = Object.entries(defaultInstance);
42✔
28
  entries.forEach(([key, value]) => {
42✔
29
    if (typeof value === 'function') {
97✔
30
      collectMethod(defaultInstance, key, options);
4✔
31
    } else if (value !== undefined) {
93✔
32
      options.fields[key] = value;
67✔
33
    }
34
  });
35
  // push a mixin to the options to initialize the data fields
36
  options.mixins.push({
42✔
37
    data() {
38
      // deep clone the fields, so that the data of the Vue instance is
39
      // independent of the class instance.
40
      return clone(options.fields);
21✔
41
    },
42
  });
43
}
44

45
export default collectData;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc