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

react-nl2br

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-nl2br - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

4

index.js

@@ -7,6 +7,4 @@ 'use strict';

module.exports = function(str) {
if (typeof str === 'number') {
if (typeof str !== 'string') {
return str;
} else if (typeof str !== 'string') {
return '';
}

@@ -13,0 +11,0 @@

{
"name": "react-nl2br",
"version": "0.4.1",
"version": "0.5.0",
"description": "newlines like '\\n', '\\n\\r' to <br /> for React",

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

@@ -26,26 +26,38 @@ const nl2br = require('.');

it('should return an empty string if the param is undefined', function () {
it('should return undefined if the param is undefined', function () {
const result = nl2br(undefined);
const expected = '';
const expected = undefined;
assert.deepEqual(expected, result);
});
it('should return an empty string if the param is null', function () {
it('should return null if the param is null', function () {
const result = nl2br(null);
const expected = '';
const expected = null;
assert.deepEqual(expected, result);
});
it('should return an empty string if the param is an array', function () {
it('should return an array if the param is an array', function () {
const result = nl2br([]);
const expected = '';
const expected = [];
assert.deepEqual(expected, result);
});
it('should return an empty string if the param is an object', function () {
it('should return an object if the param is an object', function () {
const result = nl2br({});
const expected = '';
const expected = {};
assert.deepEqual(expected, result);
});
it('should return a boolean if the param is a boolean', function () {
const result = nl2br(false);
const expected = false;
assert.deepEqual(expected, result);
});
it('should return the given React component if the param is a React component', function () {
const component = React.createElement('p', {}, 'Lorem ipsum');
const result = nl2br(component);
assert.strictEqual(component, result);
});
});
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