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

@gooddata/js-utils

Package Overview
Dependencies
Maintainers
19
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gooddata/js-utils - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0-pbenes-show-objects-2017-03-30T08-32-52-101Z

7

lib/index.js

@@ -6,3 +6,3 @@ 'use strict';

});
exports.env = exports.date = exports.translation = exports.string = undefined;
exports.env = exports.date = exports.string = undefined;

@@ -17,6 +17,2 @@ var _string = require('./utils/string');

var _translation = require('./utils/translation');
var translationUtils = _interopRequireWildcard(_translation);
var _date = require('./utils/date');

@@ -29,4 +25,3 @@

exports.string = stringUtils;
exports.translation = translationUtils;
exports.date = dateUtils;
exports.env = envUtils;

23

lib/utils/string.js

@@ -19,2 +19,3 @@ 'use strict';

exports.simplifyText = simplifyText;
exports.parseStringToArray = parseStringToArray;

@@ -71,2 +72,24 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

return s.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase();
}
/**
* Parse string in a form of [foo, bar] to an array of objects.
* Assume alphanumeric strings in the array; if some is not alphanumeric , return null
* @param {String} str input string with the array definition
* @returns {Array} parsed array of strings
*/
function parseStringToArray(str) {
if (str) {
if (str.match(/^\[]$/)) {
// empty array of tags []
return [];
}
if (str.match(/^\[[a-zA-Z0-9]+(,[a-zA-Z0-9]+)*]$/)) {
// [foo], [foo,bar]
return str.slice(1, -1).split(',');
}
}
return null;
}
{
"name": "@gooddata/js-utils",
"version": "0.4.2",
"version": "0.5.0-pbenes-show-objects-2017-03-30T08-32-52-101Z",
"description": "Various utils shared on GoodData frontend",

@@ -13,3 +13,3 @@ "main": "lib/index.js",

"type": "git",
"url": "https://github.com/gooddata/gdc-js-utils.git"
"url": "git+https://github.com/gooddata/gdc-js-utils.git"
},

@@ -22,39 +22,37 @@ "author": "Vojtech Jasny <vojtech.jasny@gooddata.com>",

"scripts": {
"build": "rimraf lib && babel src --out-dir lib --ignore test",
"prepublish": "npm run build"
"build": "rm -rf lib && babel src --out-dir lib --ignore test",
"prepublish": "yarn run build"
},
"devDependencies": {
"babel-cli": "6.18.0",
"babel-core": "6.14.0",
"babel-loader": "6.2.10",
"babel-cli": "6.23.0",
"babel-core": "6.23.1",
"babel-loader": "6.3.2",
"babel-plugin-lodash": "3.2.11",
"babel-preset-es2015": "6.18.0",
"babel-preset-stage-2": "6.18.0",
"eslint-config-gooddata": "0.0.8",
"expect.js": "0.3.1",
"babel-preset-es2015": "6.22.0",
"babel-preset-stage-2": "6.22.0",
"eslint-config-gooddata": "0.0.9",
"exports-loader": "0.6.3",
"expose-loader": "0.7.1",
"grunt": "0.4.5",
"expose-loader": "0.7.3",
"grunt": "1.0.1",
"grunt-cli": "1.2.0",
"grunt-karma": "2.0.0",
"grunt-webpack": "1.0.14",
"gruntify-eslint": "1.2.0",
"imports-loader": "0.6.5",
"istanbul-instrumenter-loader": "1.0.0",
"gruntify-eslint": "3.1.0",
"imports-loader": "0.7.0",
"istanbul-instrumenter-loader": "2.0.0",
"json-loader": "0.5.4",
"karma": "1.3.0",
"karma": "1.5.0",
"karma-chrome-launcher": "2.0.0",
"karma-coverage": "1.1.1",
"karma-expect": "1.1.3",
"karma-junit-reporter": "1.1.0",
"karma-mocha": "1.1.1",
"karma-mocha-reporter": "2.2.0",
"karma-junit-reporter": "1.2.0",
"karma-mocha": "1.3.0",
"karma-mocha-reporter": "2.2.2",
"karma-sinon": "1.0.5",
"karma-sinon-expect": "0.1.4",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "1.8.0",
"karma-webpack": "2.0.2",
"load-grunt-tasks": "3.5.2",
"mocha": "3.0.2",
"rimraf": "2.5.4",
"sinon": "1.17.6",
"mocha": "3.2.0",
"sinon": "1.17.7",
"webpack": "1.13.2",

@@ -64,7 +62,7 @@ "webpack-dev-server": "1.16.1"

"dependencies": {
"immutable": "3.8.1",
"lodash": "4.16.1",
"moment": "2.15.1",
"moment-timezone": "0.5.5"
}
"lodash": "4.17.4",
"moment": "2.17.1",
"moment-timezone": "0.5.11"
},
"license": "UNLICENSED"
}

@@ -8,2 +8,10 @@ GDC JavaScript utilities

## Setup
1. Install [Node.js](http://nodejs.org)
2. Run `yarn install` to install the dependencies
## Development
To run **tests**, run the following command:

@@ -10,0 +18,0 @@

import * as stringUtils from './utils/string';
import * as envUtils from './utils/env';
import * as translationUtils from './utils/translation';
import * as dateUtils from './utils/date';

@@ -8,5 +7,4 @@

stringUtils as string,
translationUtils as translation,
dateUtils as date,
envUtils as env
};

@@ -52,1 +52,23 @@ import { isString, isNumber } from 'lodash';

}
/**
* Parse string in a form of [foo, bar] to an array of objects.
* Assume alphanumeric strings in the array; if some is not alphanumeric , return null
* @param {String} str input string with the array definition
* @returns {Array} parsed array of strings
*/
export function parseStringToArray(str) {
if (str) {
if (str.match(/^\[]$/)) {
// empty array of tags []
return [];
}
if (str.match(/^\[[a-zA-Z0-9]+(,[a-zA-Z0-9]+)*]$/)) {
// [foo], [foo,bar]
return str.slice(1, -1).split(',');
}
}
return null;
}
import { matches } from 'lodash';
import moment from 'moment-timezone';

@@ -8,14 +7,7 @@ import * as DateUtils from '../date';

describe('getDateTimeConfig date', () => {
let dateResponse, now, momentStub;
let now;
beforeEach(() => {
dateResponse = moment();
momentStub = sinon.stub(moment, 'tz').returns(dateResponse);
});
afterEach(() => {
momentStub.restore();
});
it('should return date with corresponding timezone', () => {
const dateResponse = moment();
const momentStub = sinon.stub(moment, 'tz').returns(dateResponse);
const date = {};

@@ -31,2 +23,4 @@ const dateTimezone = 'Europe/Prague';

expect(momentStub).to.be.calledWith(date, dateTimezone);
momentStub.restore();
});

@@ -58,3 +52,3 @@ });

const shouldBehaveCorrectlyForDate = options => {
const shouldBehaveCorrectlyForDate = (options) => {
const {

@@ -98,3 +92,3 @@ now,

const now = moment.tz('2016-03-20 15:00', 'Europe/Prague').toDate();
shouldBehaveCorrectlyForDate({ now, ...options});
shouldBehaveCorrectlyForDate({ now, ...options });
});

@@ -104,3 +98,3 @@

const now = moment.tz('2016-03-20 07:00', 'America/Los_Angeles').toDate();
shouldBehaveCorrectlyForDate({ now, ...options});
shouldBehaveCorrectlyForDate({ now, ...options });
});

@@ -110,5 +104,5 @@

const now = moment.tz('2016-03-20 20:00', 'Asia/Bangkok').toDate();
shouldBehaveCorrectlyForDate({ now, ...options});
shouldBehaveCorrectlyForDate({ now, ...options });
});
});
});
import {
randomString,
shortenText,
simplifyText
simplifyText,
parseStringToArray
} from '../string';

@@ -40,1 +41,24 @@

});
describe('parseStringToArray', () => {
it('should parse string to array correctly', () => {
const tagsConfigs = [
// valid are empty [] and a-zA-Z0-9 separated by comma [asdf], [asdf,qwer], [asdf,2]
{ tag: '[]', result: [] },
{ tag: '[asdf]', result: ['asdf'] },
{ tag: '[asdf,qwer]', result: ['asdf', 'qwer'] },
{ tag: '[asdf,2]', result: ['asdf', '2'] },
// invalid
{ tag: '[asdf', result: null },
{ tag: 'asdf]', result: null },
{ tag: '[asdf, qwer]', result: null },
{ tag: '[asdf#]', result: null },
{ tag: '[asdf?]', result: null },
{ tag: '[asdf&]', result: null }
];
tagsConfigs.forEach((tagConfig) => {
expect(parseStringToArray(tagConfig.tag)).to.eql(tagConfig.result);
});
});
});
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