Comparing version 1.1.1 to 2.0.0
14
cli.js
@@ -1,13 +0,1 @@ | ||
/* | ||
* mimer | ||
* https://github.com/heldr/mimer | ||
* | ||
* Copyright (c) 2013 Helder Santana | ||
* Licensed under the MIT license. | ||
* https://raw.github.com/heldr/mimer/master/MIT-LICENSE.txt | ||
*/ | ||
var args = process.argv, | ||
Mimer = require('./dist/mimer'); | ||
console.log( '"' + Mimer( process.argv[2] ) + '"' ); | ||
console.log(`"${require('.')(process.argv[2])}"`); |
{ | ||
"name": "mimer", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "A simple Mime type getter", | ||
"main": "dist/mimer.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "npm run lint && npm run build && jest --ci", | ||
"build": "mkdir -p dist && cp src/mimer.d.ts dist/mimer.d.ts && node transpile && uglifyjs --comments '/mimer/' dist/mimer.js -m -o dist/mimer.min.js --source-map url --mangle", | ||
"lint": "jshint src/mimer.js", | ||
"build": "node src/parser.mjs > map.js", | ||
"pretest": "npm run build", | ||
"test": "node test.mjs", | ||
"prepublish": "npm run test" | ||
@@ -17,9 +17,13 @@ }, | ||
"engines": { | ||
"node": ">= 6.0" | ||
"node": ">= 12" | ||
}, | ||
"files": [ | ||
"dist", | ||
"bin", | ||
"cli.js", | ||
"MIT-LICENSE.txt" | ||
"index.js", | ||
"index.d.ts", | ||
"safe.js", | ||
"safe.d.ts", | ||
"map.js", | ||
"README.md" | ||
], | ||
@@ -39,8 +43,4 @@ "bin": { | ||
"devDependencies": { | ||
"jest": "^27.0.6", | ||
"jshint": "^2.13.0", | ||
"request": "^2.88.2", | ||
"requirejs": "2.3.6", | ||
"uglify-js": "^3.14.1" | ||
"mime-db": "^1.49.0" | ||
} | ||
} |
@@ -1,62 +0,57 @@ | ||
Mimer [![Build Status](https://secure.travis-ci.org/data-uri/mimer.png?branch=master)](http://travis-ci.org/data-uri/mimer) [![NPM version](https://badge.fury.io/js/mimer.png)](http://badge.fury.io/js/mimer) | ||
========= | ||
# Mimer [![Build Status](https://github.com/data-uri/mimer/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/data-uri/mimer/actions/workflows/main.yml?query=branch%3Amain) | ||
A simple [MIME][mime] type getter built on top of [Node.js][nodejs]. | ||
An file extension to [MIME](http://en.wikipedia.org/wiki/MIME) type module. Uses [mime-db](https://npm.im/mime-db) data but with zero dependencies. | ||
MODULE | ||
--------- | ||
## Getting started | ||
`npm install mimer` or `npx mimer <file>`. | ||
**Browser version:**: [Minified][browserminified] (amd and CommonJS ready) [Source][browsersource] | ||
**Node.js version:** `npm install mimer` into your project | ||
### Getting started | ||
### Module | ||
```js | ||
// node and browserify | ||
const Mimer = require('mimer'); | ||
const mimer = require('mimer'); | ||
// amd (Require.js and etc) | ||
require('path/to/mimer', function (Mimer) {}); | ||
// browser (through script tag) | ||
window.Mimer | ||
mimer('.pdf'); // -> "application/pdf" | ||
mimer('pdf'); // -> "application/pdf" | ||
mimer('../readme.pdf'); // -> "application/pdf" | ||
mimer('pedefe'); // -> "application/octet-stream" | ||
``` | ||
#### Get a MIME type | ||
#### Extension Map | ||
```js | ||
Mimer('file.css'); // => "text/css" | ||
const mimer = require('mimer'); | ||
const mimerMap = require('mimer/map'); | ||
// or | ||
var mime = new Mimer(); | ||
mime.get('file.css'); // => "text/css" | ||
mimerMap.get('pdf'); // -> "application/pdf" | ||
mimerMap.set('graphql', 'application/graphql'); | ||
mimer('content.graphql'); // -> "application/graphql" | ||
``` | ||
#### Set a MIME type | ||
#### Safe mode | ||
In case you want to avoid changes on original Map for safety. | ||
```js | ||
var mime = new Mimer(); | ||
const mimer = require('mimer/safe'); | ||
const mimerMap = require('mimer/map'); | ||
mime.set('.monster', 'movie/thriller') | ||
.get('zombie.monster'); | ||
// => "movie/thriller" | ||
mime.set(['.rctycoon','.simcity'], 'cms/game'); | ||
mime.get('/land/park.rctycoon'); // => "cms/game" | ||
mime.get('maps/city.simcity'); // => "cms/game" | ||
mimerMap.set('graphql', 'application/graphql'); | ||
mimer('content.graphql'); // -> "application/octet-stream" | ||
``` | ||
CLI | ||
--------- | ||
## CLI | ||
`npm install -g mimer` (it may require Root privileges) | ||
```sh | ||
npm install -g mimer | ||
mimer readme.pdf | ||
``` | ||
or just | ||
### pritting a mime type | ||
```CLI | ||
$ mimer brand.png | ||
```sh | ||
npx mimer readme.pdf | ||
``` | ||
DEVELOPING | ||
---------- | ||
## Contribute | ||
```CLI | ||
Just create a new Github Codespace or: | ||
```sh | ||
$ git clone https://github.com/data-uri/mimer.git | ||
$ cd mimer | ||
$ npm i | ||
@@ -66,12 +61,4 @@ $ npm test | ||
Build web version with: | ||
## [Changelog](https://github.com/data-uri/mimer/releases). | ||
```CLI | ||
$ npm run build | ||
``` | ||
## Release notes | ||
See more in [Releases section](https://github.com/data-uri/mimer/releases). | ||
## License | ||
@@ -81,7 +68,1 @@ | ||
(c) [Helder Santana](http://heldr.com) | ||
[nodejs]: http://nodejs.org/download | ||
[bower]: http://bower.io | ||
[mime]: http://en.wikipedia.org/wiki/MIME | ||
[browserminified]: https://raw.github.com/heldr/mimer/master/dist/mimer.min.js | ||
[browsersource]: https://raw.github.com/heldr/mimer/master/dist/mimer.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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
1
44380
177
67
1