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

is-regex

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

is-regex - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

116

.jscs.json
{
"es3": true,
"additionalRules": [],
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
"requireSemicolons": true,
"disallowMultipleSpaces": true,
"disallowIdentifierNames": [],
"requireCurlyBraces": {
"allExcept": [],
"keywords": ["if", "else", "for", "while", "do", "try", "catch"]
},
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],

@@ -10,2 +21,17 @@

"disallowSpaceBeforeComma": true,
"disallowSpaceAfterComma": false,
"disallowSpaceBeforeSemicolon": true,
"disallowNodeTypes": [
"DebuggerStatement",
"ForInStatement",
"LabeledStatement",
"SwitchCase",
"SwitchStatement",
"WithStatement"
],
"requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] },
"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },

@@ -23,3 +49,3 @@ "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },

"disallowQuotedKeysInObjects": "allButReserved",
"disallowQuotedKeysInObjects": { "allExcept": ["reserved"] },

@@ -59,3 +85,3 @@ "disallowSpaceAfterObjectKeys": true,

"requireDotNotation": true,
"requireDotNotation": { "allExcept": ["keywords"] },

@@ -69,4 +95,86 @@ "requireParenthesesAroundIIFE": true,

"mark": "'"
}
},
"disallowOperatorBeforeLineBreak": [],
"requireSpaceBeforeKeywords": [
"do",
"for",
"if",
"else",
"switch",
"case",
"try",
"catch",
"finally",
"while",
"with",
"return"
],
"validateAlignedFunctionParameters": {
"lineBreakAfterOpeningBraces": true,
"lineBreakBeforeClosingBraces": true
},
"requirePaddingNewLinesBeforeExport": true,
"validateNewlineAfterArrayElements": {
"maximum": 1
},
"requirePaddingNewLinesAfterUseStrict": true,
"disallowArrowFunctions": true,
"disallowMultiLineTernary": true,
"validateOrderInObjectKeys": "asc-insensitive",
"disallowIdenticalDestructuringNames": true,
"disallowNestedTernaries": { "maxLevel": 1 },
"requireSpaceAfterComma": { "allExcept": ["trailing"] },
"requireAlignedMultilineParams": false,
"requireSpacesInGenerator": {
"afterStar": true
},
"disallowSpacesInGenerator": {
"beforeStar": true
},
"disallowVar": false,
"requireArrayDestructuring": false,
"requireEnhancedObjectLiterals": false,
"requireObjectDestructuring": false,
"requireEarlyReturn": false,
"requireCapitalizedConstructorsNew": {
"allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"]
},
"requireImportAlphabetized": false,
"requireSpaceBeforeObjectValues": true,
"requireSpaceBeforeDestructuredValues": true,
"disallowSpacesInsideTemplateStringPlaceholders": true,
"disallowArrayDestructuringReturn": false,
"requireNewlineBeforeSingleStatementsInIf": false,
"disallowUnusedVariables": true,
"requireSpacesInsideImportedObjectBraces": true,
"requireUseStrict": true
}

@@ -0,1 +1,12 @@

1.0.4 / 2016-02-18
=================
* [Fix] ensure that `lastIndex` is not mutated (#3)
* [Refactor] when try/catch is needed, bail early if the value lacks an own `lastIndex` data property
* [Refactor] use an early return instead of a ternary
* [Refactor] bail earlier when the value is falsy
* Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG
* [Dev Deps] update `tape`, `jscs`, `editorconfig-tools`, `eslint`, `semver`, `replace`, `nsp`, `covert`, `@ljharb/eslint-config`
* [Tests] on all the node and io.js versions; improve test matri
* [Tests] Fix tests for faked @@toStringTag
1.0.3 / 2015-01-29

@@ -2,0 +13,0 @@ =================

'use strict';
var has = require('has');
var regexExec = RegExp.prototype.exec;
var tryRegexExec = function tryRegexExec(value) {
var gOPD = Object.getOwnPropertyDescriptor;
var tryRegexExecCall = function tryRegexExec(value) {
try {
var lastIndex = value.lastIndex;
value.lastIndex = 0;
regexExec.call(value);

@@ -10,2 +16,4 @@ return true;

return false;
} finally {
value.lastIndex = lastIndex;
}

@@ -18,4 +26,16 @@ };

module.exports = function isRegex(value) {
if (typeof value !== 'object') { return false; }
return hasToStringTag ? tryRegexExec(value) : toStr.call(value) === regexClass;
if (!value || typeof value !== 'object') {
return false;
}
if (!hasToStringTag) {
return toStr.call(value) === regexClass;
}
var descriptor = gOPD(value, 'lastIndex');
var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
if (!hasLastIndexDataProperty) {
return false;
}
return tryRegexExecCall(value);
};

29

package.json
{
"name": "is-regex",
"version": "1.0.3",
"version": "1.0.4",
"description": "Is this value a JS regex? Works cross-realm/iframe, and despite ES6 @@toStringTag",

@@ -9,3 +9,6 @@ "author": "Jordan Harband",

"scripts": {
"test": "npm run lint && node test.js && npm run security",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "node --harmony --es-staging test.js",
"posttest": "npm run security",
"coverage": "covert test.js",

@@ -17,3 +20,3 @@ "coverage-quiet": "covert test.js --quiet",

"eccheck": "editorconfig-tools check *.js **/*.js > /dev/null",
"security": "nsp package"
"security": "nsp check"
},

@@ -36,11 +39,15 @@ "repository": {

],
"dependencies": {},
"dependencies": {
"has": "^1.0.1"
},
"devDependencies": {
"tape": "~3.4.0",
"covert": "1.0.0",
"jscs": "~1.10.0",
"editorconfig-tools": "~0.0.1",
"nsp": "~1.0.0",
"eslint": "~0.13.0",
"semver": "~4.2.0"
"tape": "^4.6.3",
"covert": "^1.1.0",
"jscs": "^3.0.7",
"editorconfig-tools": "^0.1.1",
"nsp": "^2.6.2",
"eslint": "^3.15.0",
"@ljharb/eslint-config": "^11.0.0",
"semver": "^5.3.0",
"replace": "^0.3.0"
},

@@ -47,0 +54,0 @@ "testling": {

@@ -40,3 +40,3 @@ #is-regex <sup>[![Version Badge][2]][1]</sup>

[1]: https://npmjs.org/package/is-regex
[2]: http://vb.teelaun.ch/ljharb/is-regex.svg
[2]: http://versionbadg.es/ljharb/is-regex.svg
[3]: https://travis-ci.org/ljharb/is-regex.svg

@@ -43,0 +43,0 @@ [4]: https://travis-ci.org/ljharb/is-regex

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

var regex = /a/g;
var fakeRegex = { valueOf: function () { return regex; }, toString: function () { return String(regex); } };
fakeRegex[Symbol.toStringTag] = function () { return 'RegExp'; };
var fakeRegex = {
toString: function () { return String(regex); },
valueOf: function () { return regex; }
};
fakeRegex[Symbol.toStringTag] = 'RegExp';
t.notOk(isRegex(fakeRegex), 'fake RegExp with @@toStringTag "RegExp" is not regex');

@@ -34,1 +37,24 @@ t.end();

});
test('does not mutate regexes', function (t) {
t.test('lastIndex is a marker object', function (st) {
var regex = /a/;
var marker = {};
regex.lastIndex = marker;
st.equal(regex.lastIndex, marker, 'lastIndex is the marker object');
st.ok(isRegex(regex), 'is regex');
st.equal(regex.lastIndex, marker, 'lastIndex is the marker object after isRegex');
st.end();
});
t.test('lastIndex is nonzero', function (st) {
var regex = /a/;
regex.lastIndex = 3;
st.equal(regex.lastIndex, 3, 'lastIndex is 3');
st.ok(isRegex(regex), 'is regex');
st.equal(regex.lastIndex, 3, 'lastIndex is 3 after isRegex');
st.end();
});
t.end();
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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