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

css-styled

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-styled - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

README.md

294

dist/styled.esm.js

@@ -9,5 +9,295 @@ /*

*/
import stringHash from 'string-hash';
import { splitComma } from '@daybrush/utils';
function hash(str) {
var hash = 5381,
i = str.length;
while(i) {
hash = (hash * 33) ^ str.charCodeAt(--i);
}
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
* integers. Since we want the results to be always positive, convert the
* signed int to an unsigned by doing an unsigned bitshift. */
return hash >>> 0;
}
var stringHash = hash;
/*
Copyright (c) 2018 Daybrush
@name: @daybrush/utils
license: MIT
author: Daybrush
repository: https://github.com/daybrush/utils
@version 1.11.0
*/
/**
* get string "string"
* @memberof Consts
* @example
import {STRING} from "@daybrush/utils";
console.log(STRING); // "string"
*/
var STRING = "string";
var OPEN_CLOSED_CHARACTERS = [{
open: "(",
close: ")"
}, {
open: "\"",
close: "\""
}, {
open: "'",
close: "'"
}, {
open: "\\\"",
close: "\\\""
}, {
open: "\\'",
close: "\\'"
}];
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
return r;
}
/**
* Check the type that the value is string.
* @memberof Utils
* @param {string} value - Value to check the type
* @return {} true if the type is correct, false otherwise
* @example
import {isString} from "@daybrush/utils";
console.log(isString("1234")); // true
console.log(isString(undefined)); // false
console.log(isString(1)); // false
console.log(isString(null)); // false
*/
function isString(value) {
return typeof value === STRING;
}
function isEqualSeparator(character, separator) {
var isCharacterSpace = character === "" || character == " ";
var isSeparatorSpace = separator === "" || separator == " ";
return isSeparatorSpace && isCharacterSpace || character === separator;
}
function findOpen(openCharacter, texts, index, length, openCloseCharacters) {
var isIgnore = findIgnore(openCharacter, texts, index);
if (!isIgnore) {
return findClose(openCharacter, texts, index + 1, length, openCloseCharacters);
}
return index;
}
function findIgnore(character, texts, index) {
if (!character.ignore) {
return null;
}
var otherText = texts.slice(Math.max(index - 3, 0), index + 3).join("");
return new RegExp(character.ignore).exec(otherText);
}
function findClose(closeCharacter, texts, index, length, openCloseCharacters) {
var _loop_1 = function (i) {
var character = texts[i].trim();
if (character === closeCharacter.close && !findIgnore(closeCharacter, texts, i)) {
return {
value: i
};
}
var nextIndex = i;
// re open
var openCharacter = find(openCloseCharacters, function (_a) {
var open = _a.open;
return open === character;
});
if (openCharacter) {
nextIndex = findOpen(openCharacter, texts, i, length, openCloseCharacters);
}
if (nextIndex === -1) {
return out_i_1 = i, "break";
}
i = nextIndex;
out_i_1 = i;
};
var out_i_1;
for (var i = index; i < length; ++i) {
var state_1 = _loop_1(i);
i = out_i_1;
if (typeof state_1 === "object") return state_1.value;
if (state_1 === "break") break;
}
return -1;
}
function splitText(text, splitOptions) {
var _a = isString(splitOptions) ? {
separator: splitOptions
} : splitOptions,
_b = _a.separator,
separator = _b === void 0 ? "," : _b,
isSeparateFirst = _a.isSeparateFirst,
isSeparateOnlyOpenClose = _a.isSeparateOnlyOpenClose,
_c = _a.isSeparateOpenClose,
isSeparateOpenClose = _c === void 0 ? isSeparateOnlyOpenClose : _c,
_d = _a.openCloseCharacters,
openCloseCharacters = _d === void 0 ? OPEN_CLOSED_CHARACTERS : _d;
var openClosedText = openCloseCharacters.map(function (_a) {
var open = _a.open,
close = _a.close;
if (open === close) {
return open;
}
return open + "|" + close;
}).join("|");
var regexText = "(\\s*" + separator + "\\s*|" + openClosedText + "|\\s+)";
var regex = new RegExp(regexText, "g");
var texts = text.split(regex).filter(function (chr) {
return chr && chr !== "undefined";
});
var length = texts.length;
var values = [];
var tempValues = [];
function resetTemp() {
if (tempValues.length) {
values.push(tempValues.join(""));
tempValues = [];
return true;
}
return false;
}
var _loop_2 = function (i) {
var character = texts[i].trim();
var nextIndex = i;
var openCharacter = find(openCloseCharacters, function (_a) {
var open = _a.open;
return open === character;
});
var closeCharacter = find(openCloseCharacters, function (_a) {
var close = _a.close;
return close === character;
});
if (openCharacter) {
nextIndex = findOpen(openCharacter, texts, i, length, openCloseCharacters);
if (nextIndex !== -1 && isSeparateOpenClose) {
if (resetTemp() && isSeparateFirst) {
return out_i_2 = i, "break";
}
values.push(texts.slice(i, nextIndex + 1).join(""));
i = nextIndex;
if (isSeparateFirst) {
return out_i_2 = i, "break";
}
return out_i_2 = i, "continue";
}
} else if (closeCharacter && !findIgnore(closeCharacter, texts, i)) {
var nextOpenCloseCharacters = __spreadArrays(openCloseCharacters);
nextOpenCloseCharacters.splice(openCloseCharacters.indexOf(closeCharacter), 1);
return {
value: splitText(text, {
separator: separator,
isSeparateFirst: isSeparateFirst,
isSeparateOnlyOpenClose: isSeparateOnlyOpenClose,
isSeparateOpenClose: isSeparateOpenClose,
openCloseCharacters: nextOpenCloseCharacters
})
};
} else if (isEqualSeparator(character, separator) && !isSeparateOnlyOpenClose) {
resetTemp();
if (isSeparateFirst) {
return out_i_2 = i, "break";
}
return out_i_2 = i, "continue";
}
if (nextIndex === -1) {
nextIndex = length - 1;
}
tempValues.push(texts.slice(i, nextIndex + 1).join(""));
i = nextIndex;
out_i_2 = i;
};
var out_i_2;
for (var i = 0; i < length; ++i) {
var state_2 = _loop_2(i);
i = out_i_2;
if (typeof state_2 === "object") return state_2.value;
if (state_2 === "break") break;
}
if (tempValues.length) {
values.push(tempValues.join(""));
}
return values;
}
/**
* divide text by comma.
* @memberof Utils
* @param {string} text - text to divide
* @return {Array} divided texts
* @example
import {splitComma} from "@daybrush/utils";
console.log(splitComma("a,b,c,d,e,f,g"));
// ["a", "b", "c", "d", "e", "f", "g"]
console.log(splitComma("'a,b',c,'d,e',f,g"));
// ["'a,b'", "c", "'d,e'", "f", "g"]
*/
function splitComma(text) {
// divide comma(,)
// "[^"]*"|'[^']*'
return splitText(text, ",");
}
/**
* Returns the index of the first element in the array that satisfies the provided testing function.
* @function
* @memberof CrossBrowser
* @param - The array `findIndex` was called upon.
* @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
* @param - Returns defaultIndex if not found by the function.
* @example
import { findIndex } from "@daybrush/utils";
findIndex([{a: 1}, {a: 2}, {a: 3}, {a: 4}], ({ a }) => a === 2); // 1
*/
function findIndex(arr, callback, defaultIndex) {
if (defaultIndex === void 0) {
defaultIndex = -1;
}
var length = arr.length;
for (var i = 0; i < length; ++i) {
if (callback(arr[i], i, arr)) {
return i;
}
}
return defaultIndex;
}
/**
* Returns the value of the first element in the array that satisfies the provided testing function.
* @function
* @memberof CrossBrowser
* @param - The array `find` was called upon.
* @param - A function to execute on each value in the array,
* @param - Returns defalutValue if not found by the function.
* @example
import { find } from "@daybrush/utils";
find([{a: 1}, {a: 2}, {a: 3}, {a: 4}], ({ a }) => a === 2); // {a: 2}
*/
function find(arr, callback, defalutValue) {
var index = findIndex(arr, callback);
return index > -1 ? arr[index] : defalutValue;
}
function getHash(str) {

@@ -14,0 +304,0 @@ return stringHash(str).toString(36);

8

package.json
{
"name": "css-styled",
"version": "1.0.2",
"version": "1.0.3",
"description": "This component is a lightweight, simple line style component.",

@@ -32,4 +32,3 @@ "main": "./dist/styled.cjs.js",

"dependencies": {
"@daybrush/utils": "^1.11.0",
"string-hash": "^1.1.3"
"@daybrush/utils": "^1.11.0"
},

@@ -41,4 +40,5 @@ "devDependencies": {

"print-sizes": "^0.2.0",
"typescript": "^4.5.0 <4.6.0"
"typescript": "^4.5.0 <4.6.0",
"string-hash": "^1.1.3"
}
}

@@ -25,2 +25,3 @@

output: "./dist/styled.esm.js",
resolve: true,
format: "es",

@@ -27,0 +28,0 @@ },

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