1// user.js
2
3const checkAge = require('./user-helper')
4
5/**
6 * @typedef {Object} User
7 * @property {string} name
8 * @property {number} age
9 */
10
11/**
12 * @param {User} user
13 */
14const createUser = (user) => {
15 if (checkAge(user)) {
16 db.save(user)
17 }
18}
1// user-helper.js
2
3/**
4 * @param {import('./user').User} user
5 */
6exports.checkAge = user => {
7 return user.age >= 18
8}