danholibraryjs 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,9 +19,13 @@ function pick(from, ...props) {
19
19
  return props.reduce((result, prop) => {
20
20
  if (typeof prop === "object") {
21
21
  const keys = Object.keysOf(prop);
22
- keys.forEach(key => result[key] = from[key]);
22
+ keys.forEach(key => {
23
+ if (key in from) {
24
+ result[key] = from[key];
25
+ }
26
+ });
23
27
  }
24
- else {
28
+ else if (prop in from) {
25
29
  result[prop] = from[prop];
26
30
  }
27
31
  return result;
@@ -7,7 +7,7 @@ exports.properties = [
7
7
  'object', 'function', 'any',
8
8
  'Date', 'RegExp', 'Promise', 'Array', 'Map', 'Set'
9
9
  ].reduce((result, primitive) => {
10
- result[`get${(0, case_extension_1.convertCase)('camel', 'pascal')}s`] = function (source, withFunctions = false) {
10
+ result[`get${case_extension_1.convertCase.call(primitive, 'camel', 'pascal')}s`] = function (source, withFunctions = false) {
11
11
  return Object.keysOf(source).reduce((result, key) => {
12
12
  if (source[key].constructor.name === primitive ||
13
13
  (withFunctions && typeof source[key] === 'function' && source[key]).constructor.name === primitive) {
@@ -9,4 +9,4 @@ declare global {
9
9
  convertCase<To extends Array<Case>, Return extends To extends [...Array<Case>, infer To] ? To : Case>(from: Case, ...to: To): (Return extends 'upper' ? Uppercase<string> : Return extends 'lower' ? Lowercase<string> : Return extends 'pascal' ? Capitalize<string> : Return extends 'camel' ? Uncapitalize<string> : string);
10
10
  }
11
11
  }
12
- export declare const convertCase: <TValue extends string, To extends Case[], Return extends To extends [...Case[], infer To_1] ? To_1 : Case>(value: TValue, from: Case, ...to: To) => Return extends "upper" ? Uppercase<TValue> : Return extends "lower" ? Lowercase<TValue> : Return extends "pascal" ? Capitalize<TValue> : Return extends "camel" ? Uncapitalize<TValue> : string;
12
+ export declare function convertCase<TValue extends string, To extends Array<Case>, Return extends To extends [...Array<Case>, infer To] ? To : Case>(this: TValue, from: Case, ...to: To): (Return extends 'upper' ? Uppercase<TValue> : Return extends 'lower' ? Lowercase<TValue> : Return extends 'pascal' ? Capitalize<TValue> : Return extends 'camel' ? Uncapitalize<TValue> : string);
@@ -51,5 +51,8 @@ const caseMap = {
51
51
  lower: (str) => str.toLowerCase(),
52
52
  }
53
53
  };
54
- const convertCase = (value, from, ...to) => to.reduce((str, toCase) => caseMap[from][toCase](str), value);
54
+ function convertCase(from, ...to) {
55
+ return to.reduce((str, toCase) => caseMap[from][toCase](str), this);
56
+ }
55
57
  exports.convertCase = convertCase;
58
+ String.prototype.convertCase = convertCase;