Skip to content

Commit

Permalink
Remove all javascripts files
Browse files Browse the repository at this point in the history
  • Loading branch information
fakoua committed Dec 24, 2019
1 parent 647be2b commit 6c5a6c1
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 125 deletions.
1 change: 0 additions & 1 deletion mod.js

This file was deleted.

14 changes: 3 additions & 11 deletions src/adapters/fetchAdapter.js → src/adapters/fetchAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { settle } from '../core/settle.ts'
import { buildURL } from '../helpers/buildURL.ts'
import { buildFullPath } from '../core/buildFullPath.ts'
const fetchAdapter = function (config) {

const fetchAdapter = function (config): Promise<any> {
// At this point:
// - config has been merged with defaults
// - request transformers have already run
Expand All @@ -11,20 +12,11 @@ const fetchAdapter = function (config) {
// Upon response settle the Promise

return new Promise(function(resolve, reject) {

// var response = {
// data: responseData,
// status: request.status,
// statusText: request.statusText,
// headers: responseHeaders,
// config: config,
// request: request
// };

let fullPath = buildFullPath(config.baseURL, config.url);

let parsed = new URL(fullPath);
let protocol = parsed.protocol || 'http:'
//let protocol = parsed.protocol || 'http:'
let path = buildURL(parsed.href, config.params, config.paramsSerializer).replace(/^\?/, '')

let headers = config.headers;
Expand Down
2 changes: 1 addition & 1 deletion src/core/InterceptorManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from '../utils.js'
import * as utils from '../utils.ts'
export class InterceptorManager {
handlers: Array<object>
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Soxa.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from '../utils.js'
import * as utils from '../utils.ts'
import { buildURL } from '../helpers/buildURL.ts'
import { InterceptorManager } from './InterceptorManager.ts'
import { dispatchRequest } from './dispatchRequest.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/core/dispatchRequest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as utils from '../utils.js'
import * as utils from '../utils.ts'
import { transformData } from './transformData.ts'
import { isCancel } from '../cancel/isCancel.ts'
import { defaults } from '../defaults.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/core/mergeConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from '../utils.js'
import * as utils from '../utils.ts'

/**
* Config-specific merge-function which creates a new config-object
Expand Down
2 changes: 1 addition & 1 deletion src/core/transformData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from '../utils.js'
import * as utils from '../utils.ts'

/**
* Transform the data for a request or a response
Expand Down
4 changes: 2 additions & 2 deletions src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as utils from './utils.js'
import * as utils from './utils.ts'
import { normalizeHeaderName } from './helpers/normalizeHeaderName.ts'
import { fetchAdapter } from './adapters/fetchAdapter.js'
import { fetchAdapter } from './adapters/fetchAdapter.ts'

var DEFAULT_CONTENT_TYPE = {
'Content-Type': 'application/x-www-form-urlencoded'
Expand Down
11 changes: 0 additions & 11 deletions src/helpers/bind.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/helpers/buildURL.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from '../utils.js'
import * as utils from '../utils.ts'

function encode(val: string) : string {
return encodeURIComponent(val).
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/normalizeHeaderName.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from '../utils.js'
import * as utils from '../utils.ts'

const normalizeHeaderName = function (headers: object, normalizedName: string): void {
utils.forEach(headers, function processHeader(value: string, name: string): void {
Expand Down
29 changes: 0 additions & 29 deletions src/helpers/spread.js

This file was deleted.

66 changes: 3 additions & 63 deletions src/utils.js → src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
'use strict';

import { bind } from './helpers/bind.js'

/*global toString:true*/

// utils is a library of generic helper functions non-specific to soxa

var toString = Object.prototype.toString;
Expand Down Expand Up @@ -75,26 +69,6 @@ function isArrayBufferView(val) {
return result;
}

/**
* Determine if a value is a String
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a String, otherwise false
*/
function isString(val) {
return typeof val === 'string';
}

/**
* Determine if a value is a Number
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Number, otherwise false
*/
function isNumber(val) {
return typeof val === 'number';
}

/**
* Determine if a value is an Object
*
Expand Down Expand Up @@ -165,16 +139,6 @@ function isURLSearchParams(val) {
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
}

/**
* Trim excess whitespace off the beginning and end of a string
*
* @param {String} str The String to trim
* @returns {String} The String freed of excess whitespace
*/
function trim(str) {
return str.replace(/^\s*/, '').replace(/\s*$/, '');
}

/**
* Iterate over an Array or an Object invoking a function for each item.
*
Expand Down Expand Up @@ -231,7 +195,7 @@ function forEach(obj, fn) {
* @param {Object} obj1 Object to merge
* @returns {Object} Result of all merge properties
*/
function merge(/* obj1, obj2, obj3, ... */) {
function merge(...args: any[]) {
var result = {};
function assignValue(val, key) {
if (typeof result[key] === 'object' && typeof val === 'object') {
Expand All @@ -255,7 +219,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
* @param {Object} obj1 Object to merge
* @returns {Object} Result of all merge properties
*/
function deepMerge(/* obj1, obj2, obj3, ... */) {
function deepMerge(...args: any[]) {
var result = {};
function assignValue(val, key) {
if (typeof result[key] === 'object' && typeof val === 'object') {
Expand All @@ -273,44 +237,20 @@ function deepMerge(/* obj1, obj2, obj3, ... */) {
return result;
}

/**
* Extends object a by mutably adding to it the properties of object b.
*
* @param {Object} a The object to be extended
* @param {Object} b The object to copy properties from
* @param {Object} thisArg The object to bind function to
* @return {Object} The resulting value of object a
*/
function extend(a, b, thisArg) {
forEach(b, function assignValue(val, key) {
if (thisArg && typeof val === 'function') {
a[key] = bind(val, thisArg);
} else {
a[key] = val;
}
});
return a;
}

export {
isArray,
isArrayBuffer,
isBuffer,
isFormData,
isArrayBufferView,
isString,
isNumber,
isObject,
isUndefined,
isDate,
isFile,
isBlob,
isFunction,
isStream,
isURLSearchParams,
forEach,
merge,
deepMerge,
extend,
trim
deepMerge
};
2 changes: 1 addition & 1 deletion src/utils_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from './utils.js'
import * as utils from './utils.ts'
import { test, assert } from '../test_deps.ts'

test(function test_utils_IsArray() {
Expand Down

0 comments on commit 6c5a6c1

Please sign in to comment.