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

postcss-normalize-timing-functions

Package Overview
Dependencies
Maintainers
7
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-normalize-timing-functions - npm Package Compare versions

Comparing version 4.0.2 to 5.0.0-rc.0

CHANGELOG.md

136

dist/index.js

@@ -1,93 +0,103 @@

'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
var _postcss = require('postcss');
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
var _postcssValueParser = require('postcss-value-parser');
var _cssnanoUtils = require("cssnano-utils");
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
var _cssnanoUtilGetMatch = require('cssnano-util-get-match');
var _cssnanoUtilGetMatch2 = _interopRequireDefault(_cssnanoUtilGetMatch);
var _map = require('./lib/map');
var _map2 = _interopRequireDefault(_map);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const getMatch = (0, _cssnanoUtilGetMatch2.default)(_map2.default);
const getValue = node => parseFloat(node.value);
function evenValues(list, index) {
return index % 2 === 0;
}
function reduce(node) {
if (node.type !== 'function') {
return false;
}
if (node.type !== 'function') {
return false;
}
const lowerCasedValue = node.value.toLowerCase();
if (!node.value) {
return;
}
if (lowerCasedValue === 'steps') {
// Don't bother checking the step-end case as it has the same length
// as steps(1)
if (getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].value.toLowerCase() === 'start') {
node.type = 'word';
node.value = 'step-start';
const lowerCasedValue = node.value.toLowerCase();
delete node.nodes;
if (lowerCasedValue === 'steps') {
// Don't bother checking the step-end case as it has the same length
// as steps(1)
if (node.nodes[0].type === 'word' && getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'start' || node.nodes[2].value.toLowerCase() === 'jump-start')) {
node.type = 'word';
node.value = 'step-start';
delete node.nodes;
return;
}
return;
}
if (node.nodes[0].type === 'word' && getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'end' || node.nodes[2].value.toLowerCase() === 'jump-end')) {
node.type = 'word';
node.value = 'step-end';
delete node.nodes;
return;
} // The end case is actually the browser default, so it isn't required.
// The end case is actually the browser default, so it isn't required.
if (node.nodes[2] && node.nodes[2].value.toLowerCase() === 'end') {
node.nodes = [node.nodes[0]];
return;
}
return false;
if (node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'end' || node.nodes[2].value.toLowerCase() === 'jump-end')) {
node.nodes = [node.nodes[0]];
return;
}
if (lowerCasedValue === 'cubic-bezier') {
const match = getMatch(node.nodes.filter(evenValues).map(getValue));
return false;
}
if (match) {
node.type = 'word';
node.value = match;
if (lowerCasedValue === 'cubic-bezier') {
const values = node.nodes.filter((list, index) => {
return index % 2 === 0;
}).map(getValue);
delete node.nodes;
if (values.length !== 4) {
return;
}
return;
}
const match = (0, _cssnanoUtils.getMatch)([['ease', [0.25, 0.1, 0.25, 1]], ['linear', [0, 0, 1, 1]], ['ease-in', [0.42, 0, 1, 1]], ['ease-out', [0, 0, 0.58, 1]], ['ease-in-out', [0.42, 0, 0.58, 1]]])(values);
if (match) {
node.type = 'word';
node.value = match;
delete node.nodes;
return;
}
}
}
exports.default = (0, _postcss.plugin)('postcss-normalize-timing-functions', () => {
return css => {
const cache = {};
function transform(value) {
return (0, _postcssValueParser.default)(value).walk(reduce).toString();
}
css.walkDecls(/(animation|transition)(-timing-function|$)/i, decl => {
const value = decl.value;
function pluginCreator() {
return {
postcssPlugin: 'postcss-normalize-timing-functions',
if (cache[value]) {
decl.value = cache[value];
OnceExit(css) {
const cache = {};
css.walkDecls(/^(-\w+-)?(animation|transition)(-timing-function)?$/i, decl => {
const value = decl.value;
return;
}
if (cache[value]) {
decl.value = cache[value];
return;
}
const result = (0, _postcssValueParser2.default)(value).walk(reduce).toString();
const result = transform(value);
decl.value = result;
cache[value] = result;
});
}
decl.value = result;
cache[value] = result;
});
};
});
module.exports = exports['default'];
};
}
pluginCreator.postcss = true;
var _default = pluginCreator;
exports.default = _default;
module.exports = exports.default;
{
"name": "postcss-normalize-timing-functions",
"version": "4.0.2",
"version": "5.0.0-rc.0",
"description": "Normalize CSS animation/transition timing functions.",
"main": "dist/index.js",
"scripts": {
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/"
"prebuild": "del-cli dist",
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
"prepublish": "yarn build"
},

@@ -15,10 +17,5 @@ "files": [

"dependencies": {
"cssnano-util-get-match": "^4.0.0",
"postcss": "^7.0.0",
"postcss-value-parser": "^3.0.0"
"cssnano-utils": "^2.0.0-rc.0",
"postcss-value-parser": "^4.1.0"
},
"devDependencies": {
"babel-cli": "^6.0.0",
"cross-env": "^5.0.0"
},
"author": {

@@ -35,4 +32,11 @@ "name": "Ben Briggs",

"engines": {
"node": ">=6.9.0"
}
"node": "^10 || ^12 || >=14.0"
},
"devDependencies": {
"postcss": "^8.2.1"
},
"peerDependencies": {
"postcss": "^8.2.1"
},
"gitHead": "8c16e67a4d24a13ac7e09a36d4faf504196efd0f"
}
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