MCPcopy
hub / github.com/faker-js/faker / octal

Method octal

src/modules/string/index.ts:414–449  ·  view source on GitHub ↗

* Returns an [octal](https://en.wikipedia.org/wiki/Octal) string. * * @param options The optional options object. * @param options.length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `1`. * @param options.prefix Pr

(
    options: {
      /**
       * The length of the string (excluding the prefix) to generate either as a fixed length or as a length range.
       *
       * @default 1
       */
      length?:
        | number
        | {
            /**
             * The minimum length of the string (excluding the prefix) to generate.
             */
            min: number;
            /**
             * The maximum length of the string (excluding the prefix) to generate.
             */
            max: number;
          };
      /**
       * Prefix for the generated number.
       *
       * @default '0o'
       */
      prefix?: string;
    } = {}
  )

Source from the content-addressed store, hash-verified

412 * @since 8.0.0
413 */
414 octal(
415 options: {
416 /**
417 * The length of the string (excluding the prefix) to generate either as a fixed length or as a length range.
418 *
419 * @default 1
420 */
421 length?:
422 | number
423 | {
424 /**
425 * The minimum length of the string (excluding the prefix) to generate.
426 */
427 min: number;
428 /**
429 * The maximum length of the string (excluding the prefix) to generate.
430 */
431 max: number;
432 };
433 /**
434 * Prefix for the generated number.
435 *
436 * @default '0o'
437 */
438 prefix?: string;
439 } = {}
440 ): string {
441 const { prefix = '0o' } = options;
442
443 let result = prefix;
444 result += this.fromCharacters(
445 ['0', '1', '2', '3', '4', '5', '6', '7'],
446 options.length ?? 1
447 );
448 return result;
449 }
450
451 /**
452 * Returns a [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) string.

Callers

nothing calls this directly

Calls 1

fromCharactersMethod · 0.95

Tested by

no test coverage detected