Faker.js生成随机路径;不起作用

Faker.js Generating random paths doesn't work

本文关键字:路径 不起作用 随机 js Faker      更新时间:2023-09-26

我正在使用faker.jshttps://www.npmjs.com/package/faker以生成随机数据。虽然当我尝试创建一个路径时,它工作得很好,就像这个

faker.system.directoryPath() + '/' + faker.system.filePath()

我总是在两者中都有未定义,所以它似乎存在,但没有返回任何内容。

以前有人用过这些方法吗?

提前感谢,如有任何帮助,我们将不胜感激。

再见

这些功能没有实现-请查看https://github.com/Marak/faker.js/blob/master/lib/system.js#L132和https://github.com/Marak/faker.js/blob/master/lib/system.js#L141

  /**
   * not yet implemented
   *
   * @method faker.system.filePath
   */
  this.filePath = function () {
    // TODO
  };

如何实现它的一些概念证明:

var faker = require('faker');
var path = require('path');
faker.directoryPath = function() {
  return path.format({base: faker.fake("{{random.words}}").replace(/ /g, path.sep).toLowerCase()})
}
console.log(faker.directoryPath() + path.sep + faker.system.fileName()) // e.g. avon're-engineered'strategist_gorgeous_wooden_fish_cambridgeshire.sm