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

caseless

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caseless - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

README.md

28

index.js

@@ -10,14 +10,16 @@ function Caseless (dict) {

} else {
if (clobber === undefined) clobber = true
if (clobber || !this.has(name)) this.dict[name] = value
else this.dict[this.has(name)] += ',' + value
return this
if (typeof clobber === 'undefined') clobber = true
var has = this.has(name)
if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value
else this.dict[has || name] = value
return has
}
}
Caseless.prototype.has = function (name) {
var lheaders = this.dict.map(function (h) {return h.toLowerCase()})
var keys = Object.keys(this.dict)
, name = name.toLowerCase()
;
name = name.toLowerCase()
for (var i=0;i<lheaders.length;i++) {
if (lheaders[i] === name) return lheaders[i]
for (var i=0;i<keys.length;i++) {
if (keys[i].toLowerCase() === name) return keys[i]
}

@@ -28,3 +30,3 @@ return false

var result, re, match
var headers = this.headers
var headers = this.dict
Object.keys(headers).forEach(function (key) {

@@ -37,3 +39,9 @@ re = new RegExp(name, 'i')

}
Caseless.prototype.swap = function (name) {
var has = this.has(name)
if (!has) throw new Error('There is no header than matches "'+name+'"')
this.dict[name] = this.dict[has]
delete this.dict[has]
}
module.exports = function (dict) {return new Caseless(dict)}
module.exports = function (dict) {return new Caseless(dict)}
{
"name": "caseless",
"version": "0.1.0",
"version": "0.2.0",
"description": "Caseless object set/get/has, very useful when working with HTTP headers.",

@@ -18,2 +18,3 @@ "main": "index.js",

],
"test": "node test.js",
"author": "Mikeal Rogers <mikeal.rogers@gmail.com>",

@@ -23,3 +24,6 @@ "license": "BSD",

"url": "https://github.com/mikeal/caseless/issues"
},
"devDependencies": {
"tape": "^2.10.2"
}
}
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