* Returns a random [network interface](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-understanding_the_predictable_network_interface_device_names). * * @param options The options to use. * @param options.interfaceType The interface type.
(
options: {
/**
* The interface type. Can be one of `en`, `wl`, `ww`.
*
* @default faker.helpers.arrayElement(['en', 'wl', 'ww'])
*/
interfaceType?: (typeof commonInterfaceTypes)[number];
/**
* The interface schema. Can be one of `index`, `slot`, `mac`, `pci`.
*
* @default faker.helpers.objectKey(['index' | 'slot' | 'mac' | 'pci'])
*/
interfaceSchema?: keyof typeof commonInterfaceSchemas;
} = {}
)
| 247 | * @since 7.4.0 |
| 248 | */ |
| 249 | networkInterface( |
| 250 | options: { |
| 251 | /** |
| 252 | * The interface type. Can be one of `en`, `wl`, `ww`. |
| 253 | * |
| 254 | * @default faker.helpers.arrayElement(['en', 'wl', 'ww']) |
| 255 | */ |
| 256 | interfaceType?: (typeof commonInterfaceTypes)[number]; |
| 257 | /** |
| 258 | * The interface schema. Can be one of `index`, `slot`, `mac`, `pci`. |
| 259 | * |
| 260 | * @default faker.helpers.objectKey(['index' | 'slot' | 'mac' | 'pci']) |
| 261 | */ |
| 262 | interfaceSchema?: keyof typeof commonInterfaceSchemas; |
| 263 | } = {} |
| 264 | ): string { |
| 265 | const { |
| 266 | interfaceType = this.faker.helpers.arrayElement(commonInterfaceTypes), |
| 267 | interfaceSchema = this.faker.helpers.objectKey(commonInterfaceSchemas), |
| 268 | } = options; |
| 269 | |
| 270 | let suffix: string; |
| 271 | let prefix = ''; |
| 272 | switch (interfaceSchema) { |
| 273 | case 'index': { |
| 274 | suffix = this.faker.string.numeric(); |
| 275 | break; |
| 276 | } |
| 277 | |
| 278 | case 'slot': { |
| 279 | suffix = `${this.faker.string.numeric()}${ |
| 280 | this.faker.helpers.maybe(() => `f${this.faker.string.numeric()}`) ?? |
| 281 | '' |
| 282 | }${this.faker.helpers.maybe(() => `d${this.faker.string.numeric()}`) ?? ''}`; |
| 283 | break; |
| 284 | } |
| 285 | |
| 286 | case 'mac': { |
| 287 | suffix = this.faker.internet.mac(''); |
| 288 | break; |
| 289 | } |
| 290 | |
| 291 | case 'pci': { |
| 292 | prefix = |
| 293 | this.faker.helpers.maybe(() => `P${this.faker.string.numeric()}`) ?? |
| 294 | ''; |
| 295 | suffix = `${this.faker.string.numeric()}s${this.faker.string.numeric()}${ |
| 296 | this.faker.helpers.maybe(() => `f${this.faker.string.numeric()}`) ?? |
| 297 | '' |
| 298 | }${this.faker.helpers.maybe(() => `d${this.faker.string.numeric()}`) ?? ''}`; |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | return `${prefix}${interfaceType}${commonInterfaceSchemas[interfaceSchema]}${suffix}`; |
| 304 | } |
| 305 | |
| 306 | /** |
no test coverage detected