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

oc-client

Package Overview
Dependencies
Maintainers
4
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oc-client - npm Package Compare versions

Comparing version

to
3.2.0

test/fixtures/components/headers/.npmignore

8

package.json
{
"name": "oc-client",
"version": "3.1.0",
"version": "3.2.0",
"description": "Node.js oc client",

@@ -41,5 +41,5 @@ "main": "index.js",

"mocha": "^5.0.0",
"oc": "^0.43.1",
"oc": "^0.44.0",
"prettier-eslint-cli": "4.7.1",
"sinon": "^5.0.0"
"sinon": "^5.0.10"
},

@@ -49,3 +49,3 @@ "dependencies": {

"nice-cache": "0.0.5",
"oc-client-browser": "1.3.1",
"oc-client-browser": "1.3.2",
"oc-empty-response-handler": "1.0.0",

@@ -52,0 +52,0 @@ "oc-template-es6": "^1.0.1",

@@ -116,3 +116,3 @@ oc-client

It will resolve a component href, will make a request to the registry, and will render the component. The callback will contain an error (if present) and rendered html.
It will resolve a component href, will make a request to the registry, and will render the component. The callback will contain an error (if present), rendered html, and details (which includes headers).

@@ -146,4 +146,4 @@ Options:

timeout: 2
}, function(err, html){
console.log(html);
}, function(err, html, details){
console.log(html, details.headers);
// => "<div>This is the header. <a>Log-out</a></div>"

@@ -155,3 +155,3 @@ });

It will make a request to the registry, and will render the components. The callback will contain an array of errors (array of `null` in case there aren't any) and an array of rendered html snippets. It will follow the same order of the request. This method will make **1** request to the registry + **n** requests for each component to get the views of components that aren't cached yet. After caching the views, this will make just **1** request to the registry.
It will make a request to the registry, and will render the components. The callback will contain an array of errors (array of `null` in case there aren't any), an array of rendered html snippets, and an array of details. It will follow the same order of the request. This method will make **1** request to the registry + **n** requests for each component to get the views of components that aren't cached yet. After caching the views, this will make just **1** request to the registry.

@@ -204,4 +204,6 @@ Components parameter:

timeout: 3.0
}, function(errors, htmls){
console.log(html);
}, function(errors, htmls, details){
for ( let i; i < htmls.length; i++) {
console.log(htmls[i], details[i].headers);
}
// => ["<div>Header</div>",

@@ -208,0 +210,0 @@ // "<p>Footer</p>",

@@ -19,3 +19,3 @@ 'use strict';

);
const processClientReponses = new ProcessClientResponse(cache, config);
const processClientResponses = new ProcessClientResponse(cache, config);

@@ -41,5 +41,6 @@ return function(components, options, callback) {

renderComponents(toDo, options, () => {
processClientReponses(toDo, options, () => {
processClientResponses(toDo, options, () => {
const errors = [],
results = [];
results = [],
details = [];
let hasErrors = false;

@@ -51,11 +52,11 @@

}
errors.push(action.result.error || null);
results.push(action.result.html);
details.push({ headers: action.result.headers });
});
if (hasErrors) {
callback(errors, results);
callback(errors, results, details);
} else {
callback(null, results);
callback(null, results, details);
}

@@ -62,0 +63,0 @@ });

@@ -92,3 +92,3 @@ 'use strict';

request(requestDetails, (error, responses) => {
request(requestDetails, (error, responses, details) => {
if (!!error || !responses || _.isEmpty(responses)) {

@@ -106,3 +106,4 @@ responses = handleErrorResponse(

response: responses,
status: 200
status: 200,
headers: details.response.headers
}

@@ -191,2 +192,3 @@ ];

action.apiResponse = response.response;
action.result.headers = response.headers;
}

@@ -193,0 +195,0 @@ }

@@ -53,8 +53,8 @@ 'use strict';

options,
(errors, results) => {
(errors, results, details) => {
if (errors) {
return callback(errors[0], results[0]);
return callback(errors[0], results[0], details[0]);
}
callback(null, results[0]);
callback(null, results[0], details[0]);
}

@@ -61,0 +61,0 @@ );

@@ -596,2 +596,56 @@ 'use strict';

});
describe('when rendering components returns details', () => {
let $errs;
let $details;
before(done => {
client.renderComponents(
[
{
name: 'headers'
}
],
{ container: false, renderInfo: false },
(err, html, details) => {
$errs = err;
$details = details;
done();
}
);
});
it('should return headers', () => {
expect($details[0].headers.header1).to.be.equal('Hello');
expect($details[0].headers.header2).to.be.equal('This is a test');
});
it('should return null errors', () => {
expect($errs).to.be.null;
});
});
describe('when rendering component returns details', () => {
let $errs;
let $details;
before(done => {
client.renderComponent(
'headers',
{ container: false, renderInfo: false },
(err, html, details) => {
$errs = err;
$details = details;
done();
}
);
});
it('should return headers', () => {
expect($details.headers.header1).to.be.equal('Hello');
expect($details.headers.header2).to.be.equal('This is a test');
});
it('should return null errors', () => {
expect($errs).to.be.null;
});
});
});

@@ -598,0 +652,0 @@