How to use webidl-conversions - 10 common examples

To help you get started, we’ve selected a few webidl-conversions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / generated / ElementCreationOptions.js View on Github external
convertInherit(obj, ret, { context = "The provided value" } = {}) {
    {
      const key = "is";
      let value = obj === undefined || obj === null ? undefined : obj[key];
      if (value !== undefined) {
        value = conversions["DOMString"](value, { context: context + " has member is that" });

        ret[key] = value;
      }
    }
  },
github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / generated / KeyboardEvent.js View on Github external
if (new.target === undefined) {
    throw new TypeError(
      "Failed to construct 'KeyboardEvent'. Please use the 'new' operator; this constructor " +
        "cannot be called as a function."
    );
  }

  if (arguments.length < 1) {
    throw new TypeError(
      "Failed to construct 'KeyboardEvent': 1 argument required, but only " + arguments.length + " present."
    );
  }
  const args = [];
  {
    let curArg = arguments[0];
    curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'KeyboardEvent': parameter 1" });
    args.push(curArg);
  }
  {
    let curArg = arguments[1];
    curArg = convertKeyboardEventInit(curArg, { context: "Failed to construct 'KeyboardEvent': parameter 2" });
    args.push(curArg);
  }

  iface.setup(this, args);
}
github flaviuse / mern-authentication / client / node_modules / jsdom / lib / jsdom / living / xmlhttprequest.js View on Github external
open(method, uri, asynchronous, user, password) {
      if (!this._ownerDocument) {
        throw new DOMException("The object is in an invalid state.", "InvalidStateError");
      }
      const flag = this[xhrSymbols.flag];
      const properties = this[xhrSymbols.properties];
      const argumentCount = arguments.length;
      if (argumentCount < 2) {
        throw new TypeError("Not enough arguments (expected at least 2)");
      }

      method = conversions.ByteString(method);
      uri = conversions.USVString(uri);
      if (user) {
        user = conversions.USVString(user);
      }
      if (password) {
        password = conversions.USVString(password);
      }

      if (!tokenRegexp.test(method)) {
        throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
      }
      const upperCaseMethod = method.toUpperCase();
      if (forbiddenRequestMethods.has(upperCaseMethod)) {
        throw new DOMException("The operation is insecure.", "SecurityError");
      }

      const { client } = properties;
github sx1989827 / DOClever / Server / node_modules / jsdom / lib / jsdom / living / generated / AddEventListenerOptions.js View on Github external
convertInherit(obj, ret, { context = "The provided value" } = {}) {
    EventListenerOptions.convertInherit(obj, ret, { context });

    {
      const key = "once";
      let value = obj === undefined || obj === null ? undefined : obj[key];
      if (value !== undefined) {
        value = conversions["boolean"](value, { context: context + " has member once that" });

        ret[key] = value;
      } else {
        ret[key] = false;
      }
    }
  },
github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / xmlhttprequest.js View on Github external
setRequestHeader(header, value) {
      const flag = this[xhrSymbols.flag];
      const properties = this[xhrSymbols.properties];

      if (arguments.length !== 2) {
        throw new TypeError("2 arguments required for setRequestHeader");
      }
      header = conversions.ByteString(header);
      value = conversions.ByteString(value);

      if (this.readyState !== XMLHttpRequest.OPENED || properties.send) {
        throw new DOMException("The object is in an invalid state.", "InvalidStateError");
      }

      value = normalizeHeaderValue(value);

      if (!tokenRegexp.test(header) || !fieldValueRegexp.test(value)) {
        throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
      }

      const lcHeader = header.toLowerCase();

      if (forbiddenRequestHeaders.has(lcHeader) || lcHeader.startsWith("sec-") || lcHeader.startsWith("proxy-")) {
        return;
github zubairghori / Ultimate_todo_list / node_modules / jsdom / lib / jsdom / living / xmlhttprequest.js View on Github external
setRequestHeader(header, value) {
      const flag = this[xhrSymbols.flag];
      const properties = this[xhrSymbols.properties];

      if (arguments.length !== 2) {
        throw new TypeError("2 arguments required for setRequestHeader");
      }
      header = conversions.ByteString(header);
      value = conversions.ByteString(value);

      if (this.readyState !== XMLHttpRequest.OPENED || properties.send) {
        throw new DOMException("The object is in an invalid state.", "InvalidStateError");
      }

      value = normalizeHeaderValue(value);

      if (!tokenRegexp.test(header) || !fieldValueRegexp.test(value)) {
        throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
      }

      const lcHeader = header.toLowerCase();

      if (forbiddenRequestHeaders.has(lcHeader) || lcHeader.startsWith("sec-") || lcHeader.startsWith("proxy-")) {
        return;
github flaviuse / mern-authentication / client / node_modules / jsdom / lib / jsdom / living / xmlhttprequest.js View on Github external
setRequestHeader(header, value) {
      const flag = this[xhrSymbols.flag];
      const properties = this[xhrSymbols.properties];

      if (arguments.length !== 2) {
        throw new TypeError("2 arguments required for setRequestHeader");
      }
      header = conversions.ByteString(header);
      value = conversions.ByteString(value);

      if (this.readyState !== XMLHttpRequest.OPENED || properties.send) {
        throw new DOMException("The object is in an invalid state.", "InvalidStateError");
      }

      value = normalizeHeaderValue(value);

      if (!tokenRegexp.test(header) || !fieldValueRegexp.test(value)) {
        throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
      }

      const lcHeader = header.toLowerCase();

      if (forbiddenRequestHeaders.has(lcHeader) || lcHeader.startsWith("sec-") || lcHeader.startsWith("proxy-")) {
        return;
      }
github flaviuse / mern-authentication / client / node_modules / jsdom / lib / jsdom / living / xmlhttprequest.js View on Github external
open(method, uri, asynchronous, user, password) {
      if (!this._ownerDocument) {
        throw new DOMException("The object is in an invalid state.", "InvalidStateError");
      }
      const flag = this[xhrSymbols.flag];
      const properties = this[xhrSymbols.properties];
      const argumentCount = arguments.length;
      if (argumentCount < 2) {
        throw new TypeError("Not enough arguments (expected at least 2)");
      }

      method = conversions.ByteString(method);
      uri = conversions.USVString(uri);
      if (user) {
        user = conversions.USVString(user);
      }
      if (password) {
        password = conversions.USVString(password);
      }

      if (!tokenRegexp.test(method)) {
        throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
      }
      const upperCaseMethod = method.toUpperCase();
      if (forbiddenRequestMethods.has(upperCaseMethod)) {
        throw new DOMException("The operation is insecure.", "SecurityError");
      }
github sx1989827 / DOClever / Server / node_modules / jsdom / lib / jsdom / living / generated / MouseEventInit.js View on Github external
convertInherit(obj, ret, { context = "The provided value" } = {}) {
    EventModifierInit.convertInherit(obj, ret, { context });

    {
      const key = "button";
      let value = obj === undefined || obj === null ? undefined : obj[key];
      if (value !== undefined) {
        value = conversions["short"](value, { context: context + " has member button that" });

        ret[key] = value;
      } else {
        ret[key] = 0;
      }
    }

    {
      const key = "buttons";
      let value = obj === undefined || obj === null ? undefined : obj[key];
      if (value !== undefined) {
        value = conversions["unsigned short"](value, { context: context + " has member buttons that" });

        ret[key] = value;
      } else {
        ret[key] = 0;
github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / generated / MouseEventInit.js View on Github external
convertInherit(obj, ret, { context = "The provided value" } = {}) {
    EventModifierInit.convertInherit(obj, ret, { context });

    {
      const key = "button";
      let value = obj === undefined || obj === null ? undefined : obj[key];
      if (value !== undefined) {
        value = conversions["short"](value, { context: context + " has member button that" });

        ret[key] = value;
      } else {
        ret[key] = 0;
      }
    }

    {
      const key = "buttons";
      let value = obj === undefined || obj === null ? undefined : obj[key];
      if (value !== undefined) {
        value = conversions["unsigned short"](value, { context: context + " has member buttons that" });

        ret[key] = value;
      } else {
        ret[key] = 0;