Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : object-classes.js
'use strict';

var assert = require('assert');
var crypto = require('crypto');
var stream = require('stream');
var hash = require('../index');
var validSha1 = /^[0-9a-f]{40}$/i;

describe('hash() objects with custom class names', function() {
  var builtinToString;
  beforeEach(function() {
    builtinToString = Object.prototype.toString;
    Object.prototype.toString = function() {
      if (this && typeof this.__className !== 'undefined') {
        return this.__className;
      }
      
      return builtinToString.apply(this, arguments);
    };
  });
  
  afterEach(function() {
    Object.prototype.toString = builtinToString;
  });
  
  it('should throw when trying to hash an unknown object', function() {
    assert.throws(function() {
      hash({a:1, __className: '[object Foo]'});
    }, /Unknown object type "foo"/);
    
    assert.throws(function() {
      hash({a:1, __className: 'Foo'});
    }, /Unknown object type/);
  });

  it('should not throw when trying to hash an unknown object with ignoreUnknown', function() {
    var opt = {ignoreUnknown: true};
    
    assert.ok(validSha1.test(hash({a:1, __className: '[object Foo]'}, opt)));
  });

  it('should not throw when trying to hash a weirdly-named object with ignoreUnknown', function() {
    var opt = {ignoreUnknown: true};
    
    assert.ok(validSha1.test(hash({a:1, __className: 'Foo'}, opt)));
  });
  
  it('should not delve further into a number of native types', function() {
    var nativeTypes = [
      'domwindow',
      'process', 'timer', 'pipe', 'tcp', 'udp', 'tty', 'statwatcher',
      'securecontext', 'connection', 'zlib', 'context', 'nodescript',
      'httpparser', 'dataview', 'signal', 'fsevent', 'tlswrap'
    ];
    
    for (var i = 0; i < nativeTypes.length; i++) {
      var obj = { foobar: 1, __className: '[object ' + nativeTypes[i] + ']' };
      var serialized = hash(obj, { algorithm: 'passthrough', encoding: 'utf8' });
      assert.strictEqual(serialized, nativeTypes[i]);
    }
  });
  
  it('should hash xml based on its string representation', function() {
    var obj = {
      __className: '[object xml]',
      toString: function() { return 'Bananä' }
    };
    
    var serialized = hash(obj, { algorithm: 'passthrough', encoding: 'utf8' });
    assert.strictEqual(serialized, 'xml:Bananä');
  });
  
  it('should hash URLs based on its string representation', function() {
    var obj = {
      __className: '[object url]',
      toString: function() { return 'https://example.com/' }
    };
    
    var serialized = hash(obj, { algorithm: 'passthrough', encoding: 'utf8' });
    assert.strictEqual(serialized, 'url:https://example.com/');
  });
  
  it('should not hash blobs without ignoreUnknown', function() {
    var obj = {
      __className: '[object blob]'
    };
    
    assert.throws(function() {
      hash(obj);
    }, /not supported/);
  });
  
  it('should ignore blobs with ignoreUnknown', function() {
    var obj = {
      __className: '[object blob]'
    };
    
    var serialized = hash(obj, {
      algorithm: 'passthrough',
      encoding: 'utf8',
      ignoreUnknown: true
    });
    
    assert.strictEqual(serialized, '[blob]');
  });
});
© 2026 GrazzMean
Page non trouvée – APK Comptoir Hammami
Jannah Theme License is not validated, Go to the theme options page to validate the license, You need a single license for each domain name.

404 :(

Oups ! Cette page est introuvable.

Il semble que nous ne puissions pas trouver ce que vous cherchez. Peut-être qu'une recherche pourrait vous aider.

Bouton retour en haut de la page