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

51degrees

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

51degrees - npm Package Compare versions

Comparing version 1.2.5 to 1.3.0

2

example.js

@@ -7,5 +7,5 @@

var parser = new Parser('trie', {properties: properties});
var parser = new Parser('51Degrees-Lite.trie', properties);
var ret = parser.parse(userAgent);
console.log(ret);

@@ -29,22 +29,20 @@ /*

var util = require('util');
var path = require('path');
var TrieParser = require('./build/Release/trie.node').TrieParser;
var PatternParser = require('./build/Release/pattern.node').PatternParser;
var defaultOptions = {
filename: './51Degrees-Lite',
properties: [
'Id',
'Canvas',
'CssTransforms',
'CssTransitions',
'History',
'Html5',
'IndexedDB',
'IsMobile',
'Json',
'PostMessage',
'Svg',
'TouchEvents',
'WebWorkers'
]
};
var defaultProperties = [
'Id',
'Canvas',
'CssTransforms',
'CssTransitions',
'History',
'Html5',
'IndexedDB',
'IsMobile',
'Json',
'PostMessage',
'Svg',
'TouchEvents',
'WebWorkers'
];
var extensions = {

@@ -55,28 +53,30 @@ 'pattern': '.dat',

function Parser(method, options) {
if (!(this instanceof Parser)) {
return new Parser(method, options);
}
if (arguments.length === 1 && typeof method !== 'string') {
options = method;
method = 'pattern';
}
options = options || {};
options.filename = options.filename || defaultOptions.filename;
options.properties = defaultOptions.properties.concat(options.properties || []);
function Parser(filename, properties) {
if (!(this instanceof Parser))
return new Parser(name, options);
if (typeof filename !== 'string')
throw new Error('data filename required');
for (var key in defaultOptions) {
if (options[key] === undefined)
options[key] = defaultOptions[key];
}
if (filename === 'pattern' || filename === 'trie')
throw new Error('please use 1.2.x, if you want to use >= 1.3.x, check api at https://github.com/yorkie/51degrees.node');
this._properties = options.properties;
if (method === 'pattern') {
if (!properties || properties.length === 0)
properties = properties || defaultProperties;
if (!util.isArray(properties))
throw new Error('properties must be an array');
var extname = path.extname(filename);
if (extname === '.trie') {
this.method = 'trie';
this._parser = new TrieParser(filename, properties.join(','));
} else if (extname === '.dat') {
this.method = 'pattern';
this._filename = options.filename + extensions['pattern'];
this._parser = new PatternParser(this._filename, this._properties.join(','));
this._parser = new PatternParser(filename, properties.join(','));
} else if (extname === '') {
this.method = 'pattern';
this._parser = new PatternParser(filename + '.dat', properties.join(','));
} else {
this.method = 'trie';
this._filename = options.filename + extensions['trie'];
this._parser = new TrieParser(this._filename, this._properties.join(','));
throw new Error('could not find data file: ' + filename);
}

@@ -97,3 +97,2 @@ }

exports.Parser = Parser;
exports.ALL_PROPERTIES = [

@@ -100,0 +99,0 @@ 'AnimationTiming',

{
"name": "51degrees",
"version": "1.2.5",
"version": "1.3.0",
"description": "51degrees c-sdk native bindings for nodejs",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,12 +12,8 @@

##### `.Parse([method, options])`
##### `.Parse(filename[, properties])`
* `method` must be one of `pattern` and `trie`, default value is: `pattern`.
* `filename` {String} your 51degrees data, lite or premium.
* `options` must be an object
* `options` {Array} optional, required properties
* `options.filename`: your 51degrees data, lite or premium
* `options.properties`: required properties
for more information, you could move to [51degrees documentation](https://51degrees.com/Support/Documentation)

@@ -27,2 +23,4 @@

* `userAgent` {String}
parse the `userAgent` given by you, and return result of that.

@@ -34,3 +32,3 @@

var Parser = require('51degrees').Parser;
var psr = new Parser('trie');
var psr = new Parser('51Degrees-Lite.dat');
var userAgent = '...'; // your userAgent in any clients(browser/ios/android)

@@ -68,3 +66,3 @@ var ret = psr.parse(userAgent);

var userAgent = '...' // your userAgent in any clients(browser/ios/android)
var psr = new Parser('trie', {properties: properties});
var psr = new Parser('51Degrees-Lite.trie', properties);
var ret = psr.parse(userAgent);

@@ -71,0 +69,0 @@ console.log(ret);

@@ -34,3 +34,3 @@ /*

test('pattern', function(t) {
var parser = new Parser('pattern', {properties: properties});
var parser = new Parser('51Degrees-Lite.dat', properties);
var ret = parser.parse(userAgent);

@@ -49,3 +49,3 @@ properties.forEach(function(property) {

}
var parser = new Parser('pattern', {properties: properties});
var parser = new Parser('51Degrees-Lite', properties);
var throwed = false;

@@ -61,3 +61,3 @@ try { parser.parse(ua); }

test('trie', function(t) {
var parser = new Parser('trie', {properties: properties});
var parser = new Parser('51Degrees-Lite.trie', properties);
var ret = parser.parse(userAgent);

@@ -64,0 +64,0 @@ properties.forEach(function(property) {

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