New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@ultraq/string-utils

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ultraq/string-utils - npm Package Compare versions

Comparing version
1.0.0
to
1.1.0
+48
string-utils.js
/*
* Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Escapes special HTML characters in a string with their entity code
* equivalents.
*
* @param {String} string
* @return {String}
* HTML escaped string, safe for use in HTML.
*/
export function escapeHtml(string) {
return typeof string !== 'string' ? string : string
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}
/**
* Returns the replacement of each placeholder in a template string with a
* corresponding replacement value.
*
* @param {String} template
* @param {...String} values
* Argument list of values or a single array of values.
* @return {String}
* Replaced template string.
*/
export function format(template, ...values) {
return template.replace(/\{(\d+)\}/g, (match, index) => values[+index] + '');
}
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/*
* Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Escapes special HTML characters in a string with their entity code
* equivalents.
*
* @param {String} string
* @return {String}
* HTML escaped string, safe for use in HTML.
*/
function escapeHtml(string) {
return typeof string !== 'string' ? string : string
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}
/**
* Returns the replacement of each placeholder in a template string with a
* corresponding replacement value.
*
* @param {String} template
* @param {...String} values
* Argument list of values or a single array of values.
* @return {String}
* Replaced template string.
*/
function format(template, ...values) {
return template.replace(/\{(\d+)\}/g, (match, index) => values[+index] + '');
}
exports.escapeHtml = escapeHtml;
exports.format = format;
+6
-5
{
"name": "@ultraq/string-utils",
"version": "1.0.0",
"version": "1.1.0",
"description": "A collection of utilities for JavaScript strings",

@@ -18,7 +18,7 @@ "author": "Emanuel Rabina <emanuelrabina@gmail.com> (http://www.ultraq.net.nz/)",

],
"main": "dist/string-utils.js",
"module": "src/StringUtils.js",
"main": "string-utils.node.js",
"module": "string-utils.js",
"scripts": {
"build": "rollup --input src/StringUtils.js --format umd --name StringUtils --output dist/string-utils.js",
"lint": "eslint src test",
"build": "rollup --input string-utils.js --format cjs --output string-utils.node.js",
"lint": "eslint string-utils.js test",
"test": "npm run lint && mocha --require babel-register",

@@ -32,2 +32,3 @@ "prepublish": "npm run build"

"eslint": "^3.19.0",
"eslint-config-ultraq": "^1.0.1",
"mocha": "^3.2.0",

@@ -34,0 +35,0 @@ "rollup": "^0.41.6"

@@ -21,3 +21,9 @@

Via bower:
```
bower install https://github.com/ultraq/string-utils.git --save
```
API

@@ -24,0 +30,0 @@ ---

{
"name": "string-utils",
"description": "A collection of utilities for JavaScript strings",
"authors": [
"Emanuel Rabina <emanuelrabina@gmail.com> (http://www.ultraq.net.nz/)"
],
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/ultraq/string-utils.git"
},
"keywords": [
"string",
"utilities",
"format",
"escape",
"html"
],
"main": "dist/string-utils.js",
"moduleType": [
"globals",
"amd",
"node"
],
"ignore": [
"/test",
".*",
"package.json"
]
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.StringUtils = global.StringUtils || {})));
}(this, (function (exports) { 'use strict';
/**
* Escapes special HTML characters in a string with their entity code
* equivalents.
*
* @param {String} string
* @return {String}
* HTML escaped string, safe for use in HTML.
*/
function escapeHtml(string) {
return typeof string !== 'string' ? string : string
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}
/**
* Returns the replacement of each placeholder in a template string with a
* corresponding replacement value.
*
* @param {String} template
* @param {...String} values
* Argument list of values or a single array of values.
* @return {String}
* Replaced template string.
*/
function format(template, ...values) {
return template.replace(/\{(\d+)\}/g, (match, index) => values[+index] + '');
}
exports.escapeHtml = escapeHtml;
exports.format = format;
Object.defineProperty(exports, '__esModule', { value: true });
})));
/**
* Escapes special HTML characters in a string with their entity code
* equivalents.
*
* @param {String} string
* @return {String}
* HTML escaped string, safe for use in HTML.
*/
export function escapeHtml(string) {
return typeof string !== 'string' ? string : string
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}
/**
* Returns the replacement of each placeholder in a template string with a
* corresponding replacement value.
*
* @param {String} template
* @param {...String} values
* Argument list of values or a single array of values.
* @return {String}
* Replaced template string.
*/
export function format(template, ...values) {
return template.replace(/\{(\d+)\}/g, (match, index) => values[+index] + '');
}