PHP 8.2.30
Preview: binary.js Size: 1.88 KB
/home/byroehnu/easepaybiz.easetack.com/node_modules/@apidevtools/json-schema-ref-parser/lib/parsers/binary.js

"use strict";

let BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;

module.exports = {
  /**
   * The order that this parser will run, in relation to other parsers.
   *
   * @type {number}
   */
  order: 400,

  /**
   * Whether to allow "empty" files (zero bytes).
   *
   * @type {boolean}
   */
  allowEmpty: true,

  /**
   * Determines whether this parser can parse a given file reference.
   * Parsers that return true will be tried, in order, until one successfully parses the file.
   * Parsers that return false will be skipped, UNLESS all parsers returned false, in which case
   * every parser will be tried.
   *
   * @param {object} file           - An object containing information about the referenced file
   * @param {string} file.url       - The full URL of the referenced file
   * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
   * @param {*}      file.data      - The file contents. This will be whatever data type was returned by the resolver
   * @returns {boolean}
   */
  canParse (file) {
    // Use this parser if the file is a Buffer, and has a known binary extension
    return Buffer.isBuffer(file.data) && BINARY_REGEXP.test(file.url);
  },

  /**
   * Parses the given data as a Buffer (byte array).
   *
   * @param {object} file           - An object containing information about the referenced file
   * @param {string} file.url       - The full URL of the referenced file
   * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
   * @param {*}      file.data      - The file contents. This will be whatever data type was returned by the resolver
   * @returns {Buffer}
   */
  parse (file) {
    if (Buffer.isBuffer(file.data)) {
      return file.data;
    }
    else {
      // This will reject if data is anything other than a string or typed array
      return Buffer.from(file.data);
    }
  }
};

Directory Contents

Dirs: 0 × Files: 5

Name Size Perms Modified Actions
127 B lr--r--r-- 2026-03-14 01:49:05
Edit Download
1.88 KB lrw-r--r-- 2026-03-05 00:19:56
Edit Download
1.75 KB lrw-r--r-- 2026-03-05 00:20:00
Edit Download
2.13 KB lrw-r--r-- 2026-03-05 00:20:07
Edit Download
1.76 KB lrw-r--r-- 2026-03-05 00:20:09
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).