New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clerk

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clerk - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

2

clerk.js

@@ -123,3 +123,3 @@ /*!

clerk.version = '0.5.2';
clerk.version = '0.5.3';

@@ -126,0 +126,0 @@ /**

@@ -6,3 +6,3 @@ /*!

*/
(function(encodeURI,encodeURIComponent,decodeURIComponent){var global=this;var extend=function(target){var source,key,i=1;while(source=arguments[i++]){for(key in source)target[key]=source[key]}return target};var asString=function(that){return Object.prototype.toString.call(that)};var isString=function(that){return asString(that)=="[object String]"};var isObject=function(that){return asString(that)=="[object Object]"};var isArray=function(that){return asString(that)=="[object Array]"};var isFunction=function(that){return asString(that)=="[object Function]"};var clerk=function(uri){return clerk.make(uri)};var previousClerk=this.clerk;this.clerk=clerk;clerk.noConflict=function(){global.clerk=previousClerk;return clerk};clerk.version="0.5.2";clerk.make=function(uri){var client,db;uri=clerk._parseURI(uri);if(db=/\/*([^\/]+)\/*$/.exec(uri.path)){uri.path=uri.path.substr(0,db.index);db=db[1]&&decodeURIComponent(db[1])}client=new clerk.Client(uri.host+uri.path,uri);return db?client.db(db):client};clerk._parseURI=function(uri){var match;if(uri){if(match=/^(https?:\/\/)(?:([^@:]+):([^@]+)@)?([^\/]+)(.*)\/*$/.exec(uri)){return{host:match[1]+match[4].replace(/\/+/g,"/"),path:match[5],user:match[2]&&decodeURIComponent(match[2]),pass:match[3]&&decodeURIComponent(match[3])}}}return{host:uri||"",path:""}};clerk.Base=function(){};clerk.Base.prototype={request:function(){var args=[].slice.call(arguments),callback=isFunction(args[args.length-1])&&args.pop(),method=args[0]||"GET",headers=args[4]||{},path=args[1]?"/"+args[1]:"";if(!("Content-Type"in headers))headers["Content-Type"]="application/json";if(!callback&&(method=="GET"||method=="HEAD"))return this;this._request(method,this.uri+path,args[2],args[3]&&JSON.stringify(args[3],/^\/_design/.test(path)&&this._replacer)||"",headers,this.auth||{},callback);return this},_request:function(method,uri,query,body,headers,auth,callback){var self=this,xhr=new XMLHttpRequest,qval=[],header,key,value;if(query){for(key in query){if(typeof(value=query[key])==="object"){value=JSON.stringify(value)}key=encodeURIComponent(key);value=encodeURIComponent(value);qval.push(key+"="+value)}uri+="?"+qval.join("&")}xhr.open(method,uri,true,auth.user,auth.pass);if(headers){for(header in headers){xhr.setRequestHeader(header,headers[header])}}if(callback)xhr.onreadystatechange=function(){if(xhr.readyState===4){var headers=self._getHeaders(xhr),data=xhr.responseText,err;if(method=="HEAD"){data=headers}else if(data){try{data=JSON.parse(data)}catch(e){err=e}if(!err){if(data.error)err=self._error(data);else data=self._response(data)}}callback(err,data,xhr.status,headers,xhr)}};xhr.send(body)},_response:function(json){var data=json.rows||json.results||json.uuids||isArray(json)&&json,meta=this._meta,i=0,len,item;if(data){data=[].slice.call(data);extend(data.__proto__=[],json).json=json;for(len=data.length;i<len;i++){item=data[i]=meta(data[i]);if(json.rows&&item.doc)item.doc=meta(item.doc)}}else{data=meta(json)}return data},_error:function(json){return extend(new Error(json.error+": "+json.reason),json)},_replacer:function(key,val){return isFunction(val)?val.toString():val},_meta:function(doc){var hasId=!doc.id^!doc._id,hasRev=!doc.rev^!doc._rev,proto;if(hasId||hasRev){proto=function(){};doc=extend(new proto,doc);proto=proto.prototype;if(hasId)proto._id=proto.id=doc._id||doc.id;if(hasRev)proto._rev=proto.rev=doc._rev||doc.rev}return doc},_headers:["cache-control","content-length","content-type","date","etag","server"],_getHeaders:function(xhr){var headers={},header,i=0;while(header=this._headers[i++]){headers[header]=xhr.getResponseHeader(header)}return headers},_:function(args,start,withDoc){var self=this,doc,id,rev;function request(method,path,options){if(!options)options={};self.request(method,path||request.p||"",options.q||request.q,options.b||request.b,options.h||request.h,options.f||request.f);return self}args=[].slice.call(args,start);request.f=isFunction(args[args.length-1])&&args.pop();request.p=isString(args[0])&&encodeURI(args.shift());request.q=args[withDoc?1:0]||{};request.h=args[withDoc?2:1]||{};if(withDoc){if(doc=request.b=args[0]){if(id=request.p||doc._id||doc.id)request.p=id;if(rev=request.q.rev||doc._rev||doc.rev)request.q.rev=rev}}return request}};clerk.Client=function(uri,auth){this.uri=uri;this.auth=auth;this._db={}};clerk.Client.prototype=extend(new clerk.Base,{db:function(name){var db=this._db;return db[name]||(db[name]=new clerk.DB(this,name,this.auth))},dbs:function(){return this._(arguments)("GET","_all_dbs")},uuids:function(count){var request=this._(arguments,+count==count?1:0);if(count>1)request.q.count=count;return request("GET","_uuids")},info:function(){return this._(arguments)("GET")},stats:function(){return this._(arguments)("GET","_stats")},log:function(){var request=this._(arguments),callback=request.f;if(!callback)return this;request.f=function(e){if(e instanceof SyntaxError)e=null;callback.apply(this,arguments)};return request("GET","_log")},tasks:function(){return this._(arguments)("GET","_active_tasks")},config:function(){var args=[].slice.call(arguments),key=isString(args[0])&&args.shift()||"",value=isString(args[0])&&args.shift();return this._(args)(value?"PUT":"GET","_config/"+key,{b:value})},replicate:function(options){return this._(arguments,1)("POST","_replicate",{b:options})}});clerk.DB=function(client,name,auth){this.client=client;this.name=name;this.uri=client.uri+"/"+encodeURIComponent(name);this.auth=auth};clerk.DB.prototype=extend(new clerk.Base,{create:function(){return this._(arguments)("PUT")},destroy:function(){return this._(arguments)("DELETE")},info:function(){return this._(arguments)("GET")},exists:function(){var request=this._(arguments),callback=request.f;if(!callback)return this;request.f=function(err,body,status,headers,xhr){callback(err,status===200,status,headers,xhr)};return request("HEAD")},get:function(){return this._(arguments)("GET")},head:function(){var self=this,request=self._(arguments),callback=request.f,id=request.p,rev;if(!callback)return this;request.f=function(err,body,status,headers,xhr){callback(err,err?body:self._meta({_id:id,_rev:headers.etag&&JSON.parse(headers.etag),contentType:headers["content-type"],contentLength:headers["content-length"]}),status,headers,xhr)};return request("HEAD")},post:function(docs){var request=this._(arguments,1);if(isArray(docs)){var callback=request.f;request.p="_bulk_docs";request.b=extend({docs:docs},request.q);request.q=null;if(callback)request.f=function(err,body){if(!err){var i=0,len=body.length,doc;for(;i<len;i++){doc=body[i];if(!doc.error)doc.ok=true}}callback.apply(this,arguments)}}else{request.b=docs}return request("POST")},put:function(){var request=this._(arguments,0,1);if(!request.p)request.p=request.b._id||request.b.id;if(!request.p)throw new Error("missing id");return request("PUT")},del:function(docs){if(isArray(docs)){var i=0,len=docs.length,doc;for(;i<len;i++){doc=docs[i],docs[i]={_id:doc._id||doc.id,_rev:doc._rev||doc.rev,_deleted:true}}return this.post.apply(this,arguments)}else{var request=this._(arguments,0,1);if(!request.p)throw new Error("missing id");return request("DELETE")}},copy:function(source,target){var request=this._(arguments,2),sourcePath=encodeURIComponent(source.id||source._id||source),targetPath=encodeURIComponent(target.id||target._id||target),sourceRev=source.rev||source._rev,targetRev=target.rev||target._rev,callback=request.f;if(sourceRev)request.q.rev=sourceRev;if(targetRev)targetPath+="?rev="+encodeURIComponent(targetRev);request.h.Destination=targetPath;if(callback)request.f=function(err,body){if(!err)body.ok=true;callback.apply(this,arguments)};return request("COPY",sourcePath)},all:function(){var request=this._(arguments),body=this._viewOptions(request.q);return request(body?"POST":"GET","_all_docs",{b:body})},find:function(view){var request=this._(arguments,1),path,body;if(isString(view)){path=view.split("/",2);path="_design/"+encodeURIComponent(path[0])+"/_view/"+encodeURIComponent(path[1])}else{path="_temp_view";body=view}body=this._viewOptions(request.q,body);return request(body?"POST":"GET",path,{b:body})},changes:function(){var request=this._(arguments);if(request.q.feed!="longpoll")delete request.q.feed;return this._changes(request)},follow:function(){var request=this._(arguments),callback=request.f;if(!callback)return this;request.q.feed="longpoll";request.f=function(err,doc){var body=doc,i=0,len=doc.length,stop;for(;i<len;i++){doc=body[i];if(stop=callback.apply(this,arguments)===false||err)break}if(!stop)this._changes(request)};return this._changes(request)},_changes:function(request){return request("GET","_changes")},update:function(handler){var request=this._(arguments,1,1),path=handler.split("/",2);path="_design/"+encodeURIComponent(path[0])+"/_update/"+encodeURIComponent(path[1]);if(request.p)path+="/"+request.p;return request(request.p?"PUT":"POST",path,{q:request.b,b:request.q})},attachment:function(doc,attachmentName){var request=this._(arguments,2);var path=encodeURIComponent(doc._id||doc.id||doc)+"/"+encodeURIComponent(attachmentName);return request("GET",path,options)},attach:function(doc,attachmentName,data){var request=this._(arguments,3);request.p=encodeURIComponent(doc._id||doc.id)+"/"+encodeURIComponent(attachmentName);if(!request.q.rev)request.q.rev=doc._rev||doc.rev;request.q.body=data;return request("PUT",path)},replicate:function(options){if(!options.source)options.source=this.name;if(!options.target)options.target=this.name;return this.client.replicate.apply(this.client,arguments)},commit:function(){return this._(arguments)("POST","_ensure_full_commit")},purge:function(revs){return this._(arguments,1)("POST","_purge",{b:revs})},compact:function(){var request=this._(arguments);return request("POST","_compact/"+(request.p||""))},vacuum:function(){return this._(arguments)("POST","_view_cleanup")},_viewOptions:function(q,body){if(q){if(q.key)q.key=JSON.stringify(q.key);if(q.startkey)q.startkey=JSON.stringify(q.startkey);if(q.endkey)q.endkey=JSON.stringify(q.endkey);if(q.stale&&q.stale!="update_after")q.stale="ok";if(q.keys){if(!body)body={};body.keys=q.keys;delete q.keys}}return body}})})(encodeURI,encodeURIComponent,decodeURIComponent);
(function(encodeURI,encodeURIComponent,decodeURIComponent){var global=this;var extend=function(target){var source,key,i=1;while(source=arguments[i++]){for(key in source)target[key]=source[key]}return target};var asString=function(that){return Object.prototype.toString.call(that)};var isString=function(that){return asString(that)=="[object String]"};var isObject=function(that){return asString(that)=="[object Object]"};var isArray=function(that){return asString(that)=="[object Array]"};var isFunction=function(that){return asString(that)=="[object Function]"};var clerk=function(uri){return clerk.make(uri)};var previousClerk=this.clerk;this.clerk=clerk;clerk.noConflict=function(){global.clerk=previousClerk;return clerk};clerk.version="0.5.3";clerk.make=function(uri){var client,db;uri=clerk._parseURI(uri);if(db=/\/*([^\/]+)\/*$/.exec(uri.path)){uri.path=uri.path.substr(0,db.index);db=db[1]&&decodeURIComponent(db[1])}client=new clerk.Client(uri.host+uri.path,uri);return db?client.db(db):client};clerk._parseURI=function(uri){var match;if(uri){if(match=/^(https?:\/\/)(?:([^@:]+):([^@]+)@)?([^\/]+)(.*)\/*$/.exec(uri)){return{host:match[1]+match[4].replace(/\/+/g,"/"),path:match[5],user:match[2]&&decodeURIComponent(match[2]),pass:match[3]&&decodeURIComponent(match[3])}}}return{host:uri||"",path:""}};clerk.Base=function(){};clerk.Base.prototype={request:function(){var args=[].slice.call(arguments),callback=isFunction(args[args.length-1])&&args.pop(),method=args[0]||"GET",headers=args[4]||{},path=args[1]?"/"+args[1]:"";if(!("Content-Type"in headers))headers["Content-Type"]="application/json";if(!callback&&(method=="GET"||method=="HEAD"))return this;this._request(method,this.uri+path,args[2],args[3]&&JSON.stringify(args[3],/^\/_design/.test(path)&&this._replacer)||"",headers,this.auth||{},callback);return this},_request:function(method,uri,query,body,headers,auth,callback){var self=this,xhr=new XMLHttpRequest,qval=[],header,key,value;if(query){for(key in query){if(typeof(value=query[key])==="object"){value=JSON.stringify(value)}key=encodeURIComponent(key);value=encodeURIComponent(value);qval.push(key+"="+value)}uri+="?"+qval.join("&")}xhr.open(method,uri,true,auth.user,auth.pass);if(headers){for(header in headers){xhr.setRequestHeader(header,headers[header])}}if(callback)xhr.onreadystatechange=function(){if(xhr.readyState===4){var headers=self._getHeaders(xhr),data=xhr.responseText,err;if(method=="HEAD"){data=headers}else if(data){try{data=JSON.parse(data)}catch(e){err=e}if(!err){if(data.error)err=self._error(data);else data=self._response(data)}}callback(err,data,xhr.status,headers,xhr)}};xhr.send(body)},_response:function(json){var data=json.rows||json.results||json.uuids||isArray(json)&&json,meta=this._meta,i=0,len,item;if(data){data=[].slice.call(data);extend(data.__proto__=[],json).json=json;for(len=data.length;i<len;i++){item=data[i]=meta(data[i]);if(json.rows&&item.doc)item.doc=meta(item.doc)}}else{data=meta(json)}return data},_error:function(json){return extend(new Error(json.error+": "+json.reason),json)},_replacer:function(key,val){return isFunction(val)?val.toString():val},_meta:function(doc){var hasId=!doc.id^!doc._id,hasRev=!doc.rev^!doc._rev,proto;if(hasId||hasRev){proto=function(){};doc=extend(new proto,doc);proto=proto.prototype;if(hasId)proto._id=proto.id=doc._id||doc.id;if(hasRev)proto._rev=proto.rev=doc._rev||doc.rev}return doc},_headers:["cache-control","content-length","content-type","date","etag","server"],_getHeaders:function(xhr){var headers={},header,i=0;while(header=this._headers[i++]){headers[header]=xhr.getResponseHeader(header)}return headers},_:function(args,start,withDoc){var self=this,doc,id,rev;function request(method,path,options){if(!options)options={};self.request(method,path||request.p||"",options.q||request.q,options.b||request.b,options.h||request.h,options.f||request.f);return self}args=[].slice.call(args,start);request.f=isFunction(args[args.length-1])&&args.pop();request.p=isString(args[0])&&encodeURI(args.shift());request.q=args[withDoc?1:0]||{};request.h=args[withDoc?2:1]||{};if(withDoc){if(doc=request.b=args[0]){if(id=request.p||doc._id||doc.id)request.p=id;if(rev=request.q.rev||doc._rev||doc.rev)request.q.rev=rev}}return request}};clerk.Client=function(uri,auth){this.uri=uri;this.auth=auth;this._db={}};clerk.Client.prototype=extend(new clerk.Base,{db:function(name){var db=this._db;return db[name]||(db[name]=new clerk.DB(this,name,this.auth))},dbs:function(){return this._(arguments)("GET","_all_dbs")},uuids:function(count){var request=this._(arguments,+count==count?1:0);if(count>1)request.q.count=count;return request("GET","_uuids")},info:function(){return this._(arguments)("GET")},stats:function(){return this._(arguments)("GET","_stats")},log:function(){var request=this._(arguments),callback=request.f;if(!callback)return this;request.f=function(e){if(e instanceof SyntaxError)e=null;callback.apply(this,arguments)};return request("GET","_log")},tasks:function(){return this._(arguments)("GET","_active_tasks")},config:function(){var args=[].slice.call(arguments),key=isString(args[0])&&args.shift()||"",value=isString(args[0])&&args.shift();return this._(args)(value?"PUT":"GET","_config/"+key,{b:value})},replicate:function(options){return this._(arguments,1)("POST","_replicate",{b:options})}});clerk.DB=function(client,name,auth){this.client=client;this.name=name;this.uri=client.uri+"/"+encodeURIComponent(name);this.auth=auth};clerk.DB.prototype=extend(new clerk.Base,{create:function(){return this._(arguments)("PUT")},destroy:function(){return this._(arguments)("DELETE")},info:function(){return this._(arguments)("GET")},exists:function(){var request=this._(arguments),callback=request.f;if(!callback)return this;request.f=function(err,body,status,headers,xhr){callback(err,status===200,status,headers,xhr)};return request("HEAD")},get:function(){return this._(arguments)("GET")},head:function(){var self=this,request=self._(arguments),callback=request.f,id=request.p,rev;if(!callback)return this;request.f=function(err,body,status,headers,xhr){callback(err,err?body:self._meta({_id:id,_rev:headers.etag&&JSON.parse(headers.etag),contentType:headers["content-type"],contentLength:headers["content-length"]}),status,headers,xhr)};return request("HEAD")},post:function(docs){var request=this._(arguments,1);if(isArray(docs)){var callback=request.f;request.p="_bulk_docs";request.b=extend({docs:docs},request.q);request.q=null;if(callback)request.f=function(err,body){if(!err){var i=0,len=body.length,doc;for(;i<len;i++){doc=body[i];if(!doc.error)doc.ok=true}}callback.apply(this,arguments)}}else{request.b=docs}return request("POST")},put:function(){var request=this._(arguments,0,1);if(!request.p)request.p=request.b._id||request.b.id;if(!request.p)throw new Error("missing id");return request("PUT")},del:function(docs){if(isArray(docs)){var i=0,len=docs.length,doc;for(;i<len;i++){doc=docs[i],docs[i]={_id:doc._id||doc.id,_rev:doc._rev||doc.rev,_deleted:true}}return this.post.apply(this,arguments)}else{var request=this._(arguments,0,1);if(!request.p)throw new Error("missing id");return request("DELETE")}},copy:function(source,target){var request=this._(arguments,2),sourcePath=encodeURIComponent(source.id||source._id||source),targetPath=encodeURIComponent(target.id||target._id||target),sourceRev=source.rev||source._rev,targetRev=target.rev||target._rev,callback=request.f;if(sourceRev)request.q.rev=sourceRev;if(targetRev)targetPath+="?rev="+encodeURIComponent(targetRev);request.h.Destination=targetPath;if(callback)request.f=function(err,body){if(!err)body.ok=true;callback.apply(this,arguments)};return request("COPY",sourcePath)},all:function(){var request=this._(arguments),body=this._viewOptions(request.q);return request(body?"POST":"GET","_all_docs",{b:body})},find:function(view){var request=this._(arguments,1),path,body;if(isString(view)){path=view.split("/",2);path="_design/"+encodeURIComponent(path[0])+"/_view/"+encodeURIComponent(path[1])}else{path="_temp_view";body=view}body=this._viewOptions(request.q,body);return request(body?"POST":"GET",path,{b:body})},changes:function(){var request=this._(arguments);if(request.q.feed!="longpoll")delete request.q.feed;return this._changes(request)},follow:function(){var request=this._(arguments),callback=request.f;if(!callback)return this;request.q.feed="longpoll";request.f=function(err,doc){var body=doc,i=0,len=doc.length,stop;for(;i<len;i++){doc=body[i];if(stop=callback.apply(this,arguments)===false||err)break}if(!stop)this._changes(request)};return this._changes(request)},_changes:function(request){return request("GET","_changes")},update:function(handler){var request=this._(arguments,1,1),path=handler.split("/",2);path="_design/"+encodeURIComponent(path[0])+"/_update/"+encodeURIComponent(path[1]);if(request.p)path+="/"+request.p;return request(request.p?"PUT":"POST",path,{q:request.b,b:request.q})},attachment:function(doc,attachmentName){var request=this._(arguments,2);var path=encodeURIComponent(doc._id||doc.id||doc)+"/"+encodeURIComponent(attachmentName);return request("GET",path,options)},attach:function(doc,attachmentName,data){var request=this._(arguments,3);request.p=encodeURIComponent(doc._id||doc.id)+"/"+encodeURIComponent(attachmentName);if(!request.q.rev)request.q.rev=doc._rev||doc.rev;request.q.body=data;return request("PUT",path)},replicate:function(options){if(!options.source)options.source=this.name;if(!options.target)options.target=this.name;return this.client.replicate.apply(this.client,arguments)},commit:function(){return this._(arguments)("POST","_ensure_full_commit")},purge:function(revs){return this._(arguments,1)("POST","_purge",{b:revs})},compact:function(){var request=this._(arguments);return request("POST","_compact/"+(request.p||""))},vacuum:function(){return this._(arguments)("POST","_view_cleanup")},_viewOptions:function(q,body){if(q){if(q.key)q.key=JSON.stringify(q.key);if(q.startkey)q.startkey=JSON.stringify(q.startkey);if(q.endkey)q.endkey=JSON.stringify(q.endkey);if(q.stale&&q.stale!="update_after")q.stale="ok";if(q.keys){if(!body)body={};body.keys=q.keys;delete q.keys}}return body}})})(encodeURI,encodeURIComponent,decodeURIComponent);
//# sourceMappingURL=clerk.min.js.map

@@ -0,1 +1,7 @@

0.5.3 / 2014-01-04
==================
* Fix error handling on HEAD requests
0.5.2 / 2013-12-31

@@ -2,0 +8,0 @@ ==================

@@ -86,2 +86,3 @@ /*!

}, callback && function(err, res, data) {
if (err) return callback(err);
if (method === 'HEAD') data = res.headers;

@@ -88,0 +89,0 @@ else if (!err && data) {

{
"name": "clerk",
"description": "CouchDB library for Node and the browser",
"version": "0.5.2",
"version": "0.5.3",
"author": "Michael Phan-Ba <michael@mikepb.com>",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/mikepb/clerk",

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