Skip to content

Commit

Permalink
Add new helpers submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Oct 24, 2023
1 parent 17f0c1e commit f8f71c6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@
"./extensions": {
"require": "./src/extensions/ua-parser-extensions.js",
"import": "./src/extensions/ua-parser-extensions.mjs"
},
"./helpers": {
"require": "./src/extensions/ua-parser-helpers.js",
"import": "./src/extensions/ua-parser-helpers.mjs"
}
},
"files": [
Expand Down
6 changes: 6 additions & 0 deletions script/build-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const modules = [
dest : 'src/extensions/ua-parser-extensions.mjs',
title : 'ua-parser-js/extensions',
replacements : []
},
{
src : 'src/helpers/ua-parser-helpers.js',
dest : 'src/helpers/ua-parser-helpers.mjs',
title : 'ua-parser-js/helpers',
replacements : []
}
];

Expand Down
11 changes: 11 additions & 0 deletions src/helpers/ua-parser-helpers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Type definitions for Helpers submodule of UAParser.js v2.0.0-beta.1
// Project: https://github.com/faisalman/ua-parser-js
// Definitions by: Faisal Salman <https://github.com/faisalman>

import { IResult } from "../main/ua-parser";

declare function isAppleSilicon(res:IResult): boolean;

export {
isAppleSilicon
}
20 changes: 20 additions & 0 deletions src/helpers/ua-parser-helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
///////////////////////////////////////////////
/* Helpers for UAParser.js v2.0.0-beta.1
https://github.com/faisalman/ua-parser-js
Author: Faisal Salman <[email protected]>
AGPLv3 License */
//////////////////////////////////////////////

/*jshint esversion: 6 */

const { CPU, OS } = require('../enums/ua-parser-enums');

const isAppleSilicon = function (res) {
return res.os.is(OS.MACOS) && res.cpu.is(CPU.ARM);
}

module.exports = {
isAppleSilicon
}

// TODO: create test

0 comments on commit f8f71c6

Please sign in to comment.