@easyv/utils
Advanced tools
Comparing version 0.0.24 to 0.0.25
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,15 +10,45 @@ value: true | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _d3Color2 = require("d3-color"); | ||
var getMulticolor = function getMulticolor(_ref) { | ||
var stops = _ref.stops, | ||
angle = _ref.angle, | ||
opacity = _ref.opacity; | ||
var result = 'linear-gradient(' + angle + 'deg, '; | ||
stops.sort(function (a, b) { | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var isDesc = function isDesc(arr) { | ||
return arr.reduce(function (prev, _ref, index) { | ||
var offset = _ref.offset; | ||
if (prev == true) return prev; | ||
return arr[index + 1] ? offset > arr[index + 1].offset : prev; | ||
}, false); | ||
}; | ||
var sortColor = function sortColor(stops) { | ||
var _stops = stops.map(function (item) { | ||
return _objectSpread({}, item); | ||
}); | ||
_stops.sort(function (a, b) { | ||
return a.offset - b.offset; | ||
}); | ||
for (var i = 0, j = stops.length; i < j; i++) { | ||
var _stops$i = stops[i], | ||
return _stops; | ||
}; | ||
var getStops = function getStops(stops) { | ||
if (isDesc(stops)) return sortColor(stops); | ||
return stops; | ||
}; | ||
var getMulticolor = function getMulticolor(_ref2) { | ||
var stops = _ref2.stops, | ||
angle = _ref2.angle, | ||
opacity = _ref2.opacity; | ||
var result = 'linear-gradient(' + angle + 'deg, '; | ||
var _stops = getStops(stops); | ||
for (var i = 0, j = _stops.length; i < j; i++) { | ||
var _stops$i = _stops[i], | ||
_stops$i$color = _stops$i.color, | ||
@@ -40,6 +72,6 @@ color = _stops$i$color === void 0 ? '#fff' : _stops$i$color, | ||
var getColor = function getColor(_ref2) { | ||
var type = _ref2.type, | ||
pure = _ref2.pure, | ||
linear = _ref2.linear; | ||
var getColor = function getColor(_ref3) { | ||
var type = _ref3.type, | ||
pure = _ref3.pure, | ||
linear = _ref3.linear; | ||
@@ -46,0 +78,0 @@ if (type == 'pure') { |
{ | ||
"name": "@easyv/utils", | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
161774
4127