Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-stringprep

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-stringprep - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

19

index.js

@@ -33,3 +33,6 @@ 'use strict';

StringPrep.prototype.UNHANDLED_FALLBACK = 'Unhandled JS fallback'
StringPrep.prototype.LIBICU_NOT_AVAILABLE = 'libicu unavailable'
StringPrep.prototype.useJsFallbacks = true
StringPrep.prototype.prepare = function(value) {

@@ -42,5 +45,11 @@ this.value = value

} catch (e) {}
if (false === this.useJsFallbacks)
throw new Error(this.LIBICU_NOT_AVAILABLE)
return this.jsFallback()
}
StringPrep.prototype.isNative = function() {
return (null !== this.stringPrep)
}
StringPrep.prototype.jsFallback = function() {

@@ -69,5 +78,13 @@ switch (this.operation) {

StringPrep.prototype.disableJsFallbacks = function() {
this.useJsFallbacks = false
}
StringPrep.prototype.enableJsFallbacks = function() {
this.useJsFallbacks = true
}
module.exports = {
toUnicode: toUnicode,
StringPrep: StringPrep
}
}

2

package.json
{
"name": "node-stringprep",
"version": "0.2.2",
"version": "0.2.3",
"main": "index.js",

@@ -5,0 +5,0 @@ "description": "ICU StringPrep profiles",

@@ -5,2 +5,3 @@ 'use strict';

/* jshint -W030 */
describe('Should use JS fallbacks for StringPrep', function() {

@@ -69,2 +70,50 @@

})
})
describe('Can disable fallbacks', function() {
var StringPrep = proxyquire('../index', { 'bindings': null }).StringPrep
it('Should allow javascript fallbacks to be disabled', function(done) {
var prep = new StringPrep('nameprep')
try {
prep.disableJsFallbacks()
prep.prepare('UPPERCASE')
done('Should have thrown exception')
} catch (e) {
e.message.should.equal(prep.LIBICU_NOT_AVAILABLE)
done()
}
})
it('Should allow javascript fallbacks to be re-enabled', function(done) {
var prep = new StringPrep('nameprep')
try {
prep.disableJsFallbacks()
prep.prepare('UPPERCASE')
done('Should have thrown exception')
} catch (e) {
e.message.should.equal(prep.LIBICU_NOT_AVAILABLE)
prep.enableJsFallbacks()
prep.prepare('UPPERCASE')
done()
}
})
})
describe('\'isNative\' method test', function() {
it('Reports true with native', function() {
var StringPrep = require('../index').StringPrep
var prep = new StringPrep('resourceprep')
prep.isNative().should.be.true
})
it('Reports false without native', function() {
var StringPrep = proxyquire('../index', { 'bindings': null }).StringPrep
var prep = new StringPrep('resourceprep')
prep.isNative().should.be.false
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc