New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

css-font-face-src

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-font-face-src - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

dist/ts/grammar/index.d.ts

4

dist/css-font-face-src.js

@@ -1,2 +0,2 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.cssFontFaceSrc = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.cssFontFaceSrc = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){
/*

@@ -706,2 +706,2 @@ * Generated by PEG.js 0.10.0.

},{}]},{},[2])(2)
});
});
{
"name": "css-font-face-src",
"version": "1.0.0",
"version": "2.0.0",
"description": "A CSS @font-face src property value parser",
"main": "dist/css-font-face-src.js",
"main": "dist/ts/index.js",
"types": "dist/ts/index.d.ts",
"browser": "dist/umd/index.js",
"scripts": {
"grammar": "pegjs -o lib/grammar/index.js lib/grammar/grammar.peg",
"jshint": "jshint lib/ --exclude lib/grammar/index.js test/",
"specs": "jasmine-node test/ --captureExceptions",
"test": "npm run grammar && npm run jshint && npm run specs",
"umd": "browserify --standalone cssFontFaceSrc lib/index.js | derequire > dist/css-font-face-src.js",
"smoketest": "phantomjs test/loadPage.js test/dist_test.html | grep font.woff",
"dist": "npm run umd && npm run smoketest"
"build": "npm run build:grammar && npm run build:ts && npm run build:umd",
"build:grammar": "peggy --plugin ts-pegjs -d util:../util -o src/grammar/index.ts src/grammar/grammar.peg # the ../util path is relative to src/grammar, i.e. where the output file src/grammar/index.ts sits",
"build:ts": "mkdir -p dist/ts && tsc",
"build:umd": "mkdir -p dist/umd && browserify --standalone cssFontFaceSrc src/index.ts -p [ tsify ] -o dist/umd/index.js",
"examples": "npm run examples:cjs && npm run examples:esm && npm run examples:ts",
"examples:cjs": "node examples/cjs/parse.js && node examples/cjs/serialize.js",
"examples:esm": "node examples/esm/parse.mjs && node examples/esm/serialize.mjs",
"examples:ts": "ts-node examples/ts/parse.ts && ts-node examples/ts/serialize.ts",
"test": "npm run build && npm run test:jest && npm run test:dist",
"test:dist": "npm run build:umd && npm run test:smoketest",
"test:jest": "jest",
"test:smoketest": "ts-node test/dist/loadPage.ts test/dist/dist_test.html | grep font.woff"
},

@@ -30,2 +37,8 @@ "repository": {

},
"contributors": [
{
"name": "Mobile Design Resources",
"email": "mobiledesres@outlook.com"
}
],
"license": "BSD-2-Clause",

@@ -36,9 +49,11 @@ "bugs": {

"devDependencies": {
"browserify": "^13.1.1",
"derequire": "^2.0.3",
"jasmine-node": "^1.14.3",
"jshint": "^2.9.4",
"pegjs": "^0.10.0",
"phantomjs": "^2.1.7"
"@tsconfig/recommended": "^1.0.2",
"@types/jest": "^29.4.0",
"browserify": "^13.3.0",
"puppeteer": "^19.6.1",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"ts-pegjs": "^3.0.0",
"tsify": "^5.0.4"
}
}

@@ -1,3 +0,2 @@

css-font-face-src
=================
# CSS `@font-face` rule `src` field parser &ndash; `css-font-face-src`

@@ -9,26 +8,143 @@ <a href="https://www.npmjs.org/package/css-font-face-src">

A CSS [@font-face](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face) src property value parser.
A CSS [@font-face](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face) `src` property value parser.
Example
-------
Basically it provides two operations:
* `parse`: To convert a CSS property string to an array of easily readable objects. Each object either describes a **local font** (referenced using its family name) or a **remote font** (referenced using its URL).
* `serialize`: To convert an object array back to a CSS property string.
## Examples
### JavaScript verison (CJS, using `require`)
#### Parse
```js
var parser = require('css-font-face-src');
const parser = require('css-font-face-src');
parser.parse('local("The Font"), url("font.otf") format("opentype"), url("font.woff"), local("Another Font")');
console.log(parser.parse('local("The Font"), url("font.otf") format("opentype"), url("font.woff"), local("Another Font")'));
```
will return
will return:
```js
[ { local: 'The Font' },
{ url: 'font.otf', format: 'opentype' },
{ url: 'font.woff' },
{ local: 'Another Font' } ]
[
{ local: 'The Font' },
{ url: 'font.otf', format: 'opentype' },
{ url: 'font.woff' },
{ local: 'Another Font' }
]
```
#### Serialize
```js
const parser = require('css-font-face-src');
console.log(
parser.serialize([
{ local: 'The Font' },
{ url: 'font.otf', format: 'opentype' },
{ url: 'font.woff' },
{ local: 'Another Font' }
])
);
```
will return:
```js
'local("The Font"), url("font.otf") format("opentype"), url("font.woff"), local("Another Font")'
```
### JavaScript version (ESM, using `import`)
#### Parse
```js
import { parse } from 'css-font-face-src';
console.log(parse('local("The Font"), url("font.otf") format("opentype"), url("font.woff"), local("Another Font")'));
```
will return:
```js
[
{ local: 'The Font' },
{ url: 'font.otf', format: 'opentype' },
{ url: 'font.woff' },
{ local: 'Another Font' }
]
```
#### Serialize
```js
import { serialize } from 'css-font-face-src';
console.log(
serialize([
{ local: 'The Font' },
{ url: 'font.otf', format: 'opentype' },
{ url: 'font.woff' },
{ local: 'Another Font' }
])
);
```
will return:
```js
'local("The Font"), url("font.otf") format("opentype"), url("font.woff"), local("Another Font")'
```
### TypeScript version
#### Parse
```ts
import { parse } from 'css-font-face-src';
console.log(parse('local("The Font"), url("font.otf") format("opentype"), url("font.woff"), local("Another Font")'));
```
will return:
```ts
[
{ local: 'The Font' },
{ url: 'font.otf', format: 'opentype' },
{ url: 'font.woff' },
{ local: 'Another Font' }
]
```
#### Serialize
```ts
import { serialize, FontFaceSrcItem } from 'css-font-face-src';
console.log(
serialize([
{ local: 'The Font' },
{ url: 'font.otf', format: 'opentype' },
{ url: 'font.woff' },
{ local: 'Another Font' }
] as FontFaceSrcItem[])
);
```
will return:
```ts
'local("The Font"), url("font.otf") format("opentype"), url("font.woff"), local("Another Font")'
```
## Build status
[![Build Status](https://travis-ci.org/cburgmer/css-font-face-src.svg?branch=master)](https://travis-ci.org/cburgmer/css-font-face-src)
Author
------
## Author
Christoph Burgmer. Licensed under BSD-2-Clause. Reach out [on Twitter](https://twitter.com/cburgmer).

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